• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java SQL Exception General Error

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 = "jdbc:odbc:" + 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.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is the java.sql package part of the JRE or does it have to have a SDK installed on the computer?
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What database you are using?
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic