File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Java SQL Exception General Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java SQL Exception General Error" Watch "Java SQL Exception General Error" New topic
Author

Java SQL Exception General Error

Jesse Walker
Ranch Hand

Joined: Aug 18, 2004
Posts: 50
I am just trying to learn the Java.sql class as well as odbcs, the following is my code, I have everything spelled correctly and all the cases match up, I will post my code below and the printStackTrace from the error as well
package quote;
import java.sql.*;
/**
*
* @author tech
*/
public class Connect {
public static void main(String[] args)
{
try {
String dataSourceName = "mdbTEST";
String dbURL = "jdbcdbc:" + dataSourceName;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(dbURL, "","");
Statement s = con.createStatement();
s.execute("INSERT INTO TEST12345 VALUES('1','2')"); // Line 25
s.close(); // close the Statement to let the database know we're done with it
con.close();
}
catch (Exception e) {
System.out.println("Error: " + e);
e.printStackTrace();
}
}

/** Creates a new instance of Connect */
public Connect() {
}

}

error is the following:
java.sql.SQLException: General error

at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6987)

at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)

at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)

at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)

at quote.Connect.main(Connect.java:25)\\where my error is

Any help would be greatly appreciated, I am using DSNs.
Manhar Puri
Ranch Hand

Joined: Aug 23, 2005
Posts: 41
Jesse,

Your code looks fine to me, just check if your insert statement works from the sql editor i.e. try your insert directly on the database.

Also just check if you are actually able to get the connection successfully.

-Manhar.
[ March 29, 2007: Message edited by: Manhar Puri ]
Jesse Walker
Ranch Hand

Joined: Aug 18, 2004
Posts: 50
is the java.sql package part of the JRE or does it have to have a SDK installed on the computer?
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
If you're developing Java applications, you'll need the SDK. JRE would suffice for end users. What database are you using? Try updating your driver name to that of the library you're using.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Ratan Kumar
Ranch Hand

Joined: Jul 19, 2006
Posts: 67
What database you are using?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java SQL Exception General Error