This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes SQL Exception: General error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQL Exception: General error" Watch "SQL Exception: General error" New topic

SQL Exception: General error

Qasim Shabbir

Joined: May 12, 2002
Posts: 16
can any body know y general error occurs.. wht does it means..
i use a class to communicate with database now my test class is working fine.. but when i use my real class it throws a general error same code.
i m puzzled please help
Qasim shabbir.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

post the code, the exception, and tell us which line is throwing the exception. This will keep the guessing to a minimum.
Qasim Shabbir

Joined: May 12, 2002
Posts: 16
thanx for reply
here is my method's code of the class which is communicate to DataBase
public void addUser(User user)
throws SQLException
PreparedStatement statement;
String add="Insert into chater "+
"(id,name,nick,status,email_address,contact_no,password) "+
statement.setString(2,user.getName ());
statement.setString(3,user.getNick ());
statement.setByte (4,user.getStatus());
statement.setString(5,user.getEmail ());
statement.executeUpdate();//throws exception here
connection.commit ();
}catch(SQLException sql){
String errorMessage=
"DBConnection:addUser:Record not safe :"+sql;
throw new SQLException(errorMessage);
this is my test class snaped code which is working fine
public class testDB{
public void creatUser(){
System.out.println("testDB:main:creating user instance and fill the value");
user=new User();
user.setName ("Qasim Shabbir");
user.setNick ("Dragon Dreamz U");
user.setEmail ("");
user.setPassword ("Silent");
System.out.println("testDB:main:add user to Database");
}catch(SQLException sql){
System.out.println("testDB:main:user not added to Database "+sql);
public static void main(String arg[]) throws SQLException{
testDB test=new testDB();
test.creatUser ();
// and here is my real class code which is cozing problem.
public int registerMeToServer(ClientInfo client)
throws RemoteException
User user=client.getUser();
int id=db.getMaxId ();
user.setId (id);
Integer key=new Integer(id);
System.out.println("Server:registerMeToServer: user: " +user);
db.addUser (user);
System.out.println("Server:registerMeToServer: ClientID : " +id);
}catch(Exception e){
System.out.println("Server:registerMeToServer:Error : " +e);
if(clients.contains (key)){
clients.remove (key);
return id;
it throws SQLExcpetion General error
thanking you again
Qasim shabbir
Sun Certified Java Programer
Tina Coleman
Ranch Hand

Joined: Dec 12, 2001
Posts: 150
This isn't an immediate answer, unfortunately, but. . . try chaining through your SQLException to see if you can find a more descriptive problem buried in the exception trail. Do something like. . .

I've found that my 'useful' error message was sometimes buried further down the chain, and that I wasn't getting the necessary info to solve the problem until I bounced down through the chain.
Note that the Exception API also has a method getCause(). I've used the before-listed code and haven't used getCause() - just 'cause I hadn't run across it before.
Qasim Shabbir

Joined: May 12, 2002
Posts: 16
thnx 4 yr replies.. i work tht way as u said.. but its not worthy in my case i didnt found any extra information if u'll find thn please tell me.
here is the complete exception stack.
java.sql.SQLException: General error
at sun.jdbc.odbc.JdbcOdbc.createSQLException(
at sun.jdbc.odbc.JdbcOdbc.standardError(
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(
at DBConnection.addUser(
at Server.registerMeToServer(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at sun.rmi.server.UnicastServerRef.dispatch(
at sun.rmi.transport.Transport$
at Method)
at sun.rmi.transport.Transport.serviceCall(
at sun.rmi.transport.tcp.TCPTransport.handleMessages(
at sun.rmi.transport.tcp.TCPTransport$
Qasim Shabbir
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

I see that you have user.getContactNo() but I don't see where you set or initialize contact number?
I agree. Here's the link:
subject: SQL Exception: General error
It's not a secret anymore!