package java.sql does not exist error in j2me

951 Views Asked by At

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;

1

There are 1 best solutions below

0
mr_lou On

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