我的第一个JDBC程序
try {
Class.forName(”com.mysql.jdbc.Driver”);
String connectionUrl1 = “jdbc:mysql://localhost/test?” +
“user=root&password=admin”;
Connection con = DriverManager.getConnection(connectionUrl1);
System.out.println(”I have connect database”);
Statement sm=con.createStatement();
sm.executeUpdate(”delete from `test`.`test` where id=1″);
sm.executeUpdate(”insert into `test`.`test` values(1,’Visual J++ Bible’,38)”);
/*sm.executeUpdate(”insert into test”+”values(3,’java language’,40)”);*/
sm.close();
con.close();
} catch (SQLException e) {
System.out.println(”SQL Exception: “+ e.toString());
} catch (ClassNotFoundException cE) {
System.out.println(”Class Not Found Exception: “+ cE.toString());
}
