Is J2ME supports to connect mssqlserver database like java????
I shows following error in imports,
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
error: package java.sql does not exist import java.sql.Connection;
You cannot connect directly to an SQL-server with JavaME.
There might be 3rd party libs available that'll let you do it, but most developers use a middle-link instead:
Have your MIDlet call a server-side script (PHP or ASPX or a Servlet).
http://www.example.com/sqlinterface.php?action=insert&name=John&address=Home
Then your server-script will insert the entry into the database.
Here's an example using a Servlet:
http://www.java-tips.org/java-me-tips/midp/connecting-to-databases-like-mysql-sql-server-or-oracle-on-j2me-de.html
Related
I want to import the packages, for example:
import java.io.PrintWriter;
import java.text.DateFormat;
import java.util.Date;
these packages have already existed so it doesn't pop up any error messages.
When I want to import others packages:
import com.businessobjects.rebean.wi.DocumentInstance;
import com.businessobjects.rebean.wi.Prompt;
import com.businessobjects.rebean.wi.Prompts;
import com.businessobjects.rebean.wi.ReportEngine;
import com.businessobjects.rebean.wi.ReportEngines;
import com.crystaldecisions.enterprise.ocaframework.ServiceNames;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.plugin.desktop.folder.IFolder;
It will say "the import cannot be resolved", but where I can get the jar files to resolve these problems?
I tried to search these jar files in the java lib folder but was not able to get them.
Can anyone tell the exact folder path for these jar files, if it is there?
Or where can I download those packages.....
I found the website (https://help.sap.com/doc/javadocs_bip_42/4.2/en-US/bip/en/com/crystaldecisions/sdk/exception/package-summary.html) but I still don't know how to import it......
You'll need rebean.wi.adapter.jar and cecore.jar. They are located in the following directory with BO client or server software is installed:
C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\java\lib
Note that these are not available publicly -- you will need to install the software.
I am using eclipse for core java and its working fine. Now I downloaded another eclipse for java ee and I am using tomcat server but in my new eclipse java files are not getting loaded
Below mentioned imports are showing the error of import cannot be resolved while they are working fine in my old eclipse(I think there is some problem with build path ) -
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
While the below-mentioned imports do not show any error-
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.mysql.jdbc.ResultSet;
Sample Image of error:
A package at the top should be used, a deep src sub-directory like: src/aaa/bbb/ccc.
package aaa.bbb.ccc;
import ...
Reason: using the default package (immediately under the root) is actually
never done since java 1.2. For that I find the missing package suspicious.
The following is wrong:
import com.mysql.jdbc.ResultSet;
It should be:
import java.sql.ResultSet;
Reason for JDBC using database vendor specific libraries is bad style.
Entirely sure on a cause for your errors in eclipse I am not sure. A refresh, Alt+F5 might be useful if the error was a fluke.
If the JDK is actually java 9 I would expect import problems too, as then you would need to gather the JDK modules piecewise. That does not seem to be the case here.
Check if you have set the JDKs correctly in your IDE and in the project.
So i made it finally to the final stage of my simple java app that runs under windows and is used to get the user name and log it in an remote excel file. up until now everything is ok.
When i Externelize (does that word exist?) the app to make it a runnable jar the size of the app was 22Mo! wich is huge since i want to use it in an email (outlook).
Here come the question (finally). Can i delete any of the default java jars in the classpath and the app will still run ?? if yes, which ones??
NB: i tried including the imports in the SS if it does help
NB2: the Jar of the app it self is just 20Ko , the ressources are around 22Mo .
By the way thank you all for helping me make this app it was thanks to this website eventhought i didn't ask any question up until now you'll still answered them all..You rock !
Those are my imports:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.wb.swt.SWTResourceManager;
EDIT: So after the discussions i managed to reduce the size of the app to 8Mo by deleting some of the jar in the referenced library (org.ibm.icu.jar). The app still runs perfectly without it
A jar file is just a zip file, so what I would do is simply unzip the file and see what comes with it and what is large. The standard java libraries, should not even be part of your JAR as they are part of the JRE.
However, my suspicion is that you use Apache POI and that is huge. So if you are writing to an Excel file you might have to stick with that size or find another library.
You could for example write the output as CSV which is very lightweight.
I have downloaded. using git, the Google I/O app from there website and I can't get it to compile. Android Studio is giving me the error: "the package javax.servlet does not exists" from the following code
package com.google.android.apps.iosched.gcm.server.cron;
import com.google.android.apps.iosched.gcm.server.BaseServlet;
import com.google.android.apps.iosched.gcm.server.db.DeviceStore;
import java.io.IOException;
import java.io.PrintWriter;`
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
How will I be able to install the package?
Following this tutorial http://netbeans.org/kb/docs/javaee/maven-osgiservice-cdi.html
I have managed to create a simple OSGI bundle and a client web application. I placed a managed bean into the web application client. The managed been calls a interface placed into the OSGI bundle. I successfully compile the code.
Now the interesting part is can I place a data into the OSGI bundle which can make queries to the database. This is the code that I placed into the OSGI bundle:
package com.test;
import javax.ejb.Remote;
/** include default packages for Beans */
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
// or import javax.faces.bean.SessionScoped;
import javax.inject.Named;
/** include package for SHA-256 encryption */
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/** include SQL Packages */
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import javax.annotation.Resource;
// or import javax.faces.bean.ManagedBean;
#Remote
public interface SL_43Remote {
#Resource(name="java:/Oracle")
private DataSource ds;
}
Betbeans 7.1 shows error: "modifier private is not allowed" and "= expected".
Maybe I'm missing some libraries or maybe OSGI bundles don't allow source code for working with databases.
Any idea how to fix the problem?
Kind Regards.
Peter
Private fields are not allowed on interfaces in Java.
This problem has nothing to do with OSGi, just the fundamentals of Java.