package org.dml;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class InsertDemo01 {
public static final String DBDRIVER = "org.gjt.mm.mysql.Driver";
public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
public static void main(String[] args) throws Exception{
Connection conn = null;
Statement stmt = null;
String sql = "insert into user(name,password,age,sex) " +
"values('陈飞鹏','www.hut.edu.cn',21,'男')";
Class.forName(DBDRIVER);
conn = DriverManager.getConnection(DBURL, "root", "root");
stmt = conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
conn.close();
}
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class InsertDemo01 {
public static final String DBDRIVER = "org.gjt.mm.mysql.Driver";
public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
public static void main(String[] args) throws Exception{
Connection conn = null;
Statement stmt = null;
String sql = "insert into user(name,password,age,sex) " +
"values('陈飞鹏','www.hut.edu.cn',21,'男')";
Class.forName(DBDRIVER);
conn = DriverManager.getConnection(DBURL, "root", "root");
stmt = conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
conn.close();
}
}