Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help me the following jdbc code and error message!

 
Jeffrey Ye
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.sql.*;

public class UseDriver {
public static void main(String[]args){
String url="jdbc:mysql://localhost/sql_test";
String userName="root";
String password="yese04";
String sql=null;
Connection conn=null;
Statement stmt=null;
//
try{
//load the driver class
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e){
System.err.println("class not found");
}
//connect database
try{
conn=DriverManager.getConnection(url,userName,password);
//create statement
stmt=conn.createStatement();
//operation the database
sql="insert into student"+"values('20','jack','2000/02/03','beijing')";
//execute the statement
stmt.executeUpdate(sql);
System.out.println("inser successful");
}
catch(SQLException e){
System.err.println("insert sql error");
}
finally{
try{
stmt.close();
conn.close();
}
catch(SQLException e){
System.err.println("close error");
}
}
}
}


error message:



#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_FLT_STACK_CHECK (0xc0000092) at pc=0x00dd0618, pid=2960, tid=2964
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode)
# Problematic frame:
# v ~RuntimeStub::init_check_patching Runtime1 stub
#
# An error report file with more information is saved as hs_err_pid2960.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
 
Shivashankar Gurumurthy
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Check the way your query is made. There is no space between table name "Student" and values. When you are concatenating those 2 strings the resulting query will look like

"insert into [B]studentvalues[/B]........."

Everything else in the code looks fine

One more thing is that print the stack trace in the exception block to get more information.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic