Connection con = null;
Statement stmt = null; // 保存到表中
String sql = "insert into website(username,userpassw) values('喜欢','不喜欢')"; try {
Class.forName("com.mysql.jdbc.Driver");
//链接对象
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/mysqlconnect", "root", "bequt");
//执行命令对象
stmt = con.createStatement();
//执行
stmt.execute(sql);
//关闭
stmt.close();
con.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}