This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Java SQL Exception General Error" Watch "Java SQL Exception General Error" New topic

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;
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
catch (Exception e) {
System.out.println("Error: " + e);

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


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

at sun.jdbc.odbc.JdbcOdbc.createSQLException(

at sun.jdbc.odbc.JdbcOdbc.standardError(

at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(

at sun.jdbc.odbc.JdbcOdbcStatement.execute(

at quote.Connect.main(\\where my error is

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

Joined: Aug 23, 2005
Posts: 41

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.

[ 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?
It is sorta covered in the JavaRanch Style Guide.
subject: Java SQL Exception General Error
It's not a secret anymore!