This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: General error

 
Deepa Krishnan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I am getting an error while closing the connection.In this code i am trying to insert the values inside the database.I am not getting this error for the first insertion.

Thanks in advance
deepa


code:

public boolean insertUser(String username,String password,String firstname,String lastname,String address,String phone,String email){

java.sql.Connection conn =null;
java.sql.Statement stmt=null;


try{
conn = ConnectionManager.getConnection();
stmt=conn.createStatement();
String s;

s="insert into user_info(user_name,password,first_name,last_name,address,phone,email) values("+ "'" +username+ "'" +", "+ "'" +password+ "'" +","+"'"+firstname+"'"+","+"'"+lastname+"'"+","+"'"+address+"'"+","+"'"+phone +"'"+","+"'"+email+"'" +" )";
stmt.executeUpdate(s);

}catch(Exception e){
System.out.println("Inside catch");
System.err.println(e.toString());
return false;
}finally{
try{
stmt.close();
conn.close();
}catch(java.sql.SQLException e){
System.out.println("Error while closing connection. "+e.toString());
}catch(NullPointerException e){

System.out.println("Null pointer exception");
}
}

return true ;
}
 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and what is that error ?
 
Heonkoo Lee
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you include the stack trace?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic