package com.sql;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class Add {
/**
* @param args
*/
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection ct;
try {
ct = DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","hequnjie");
Statement st=ct.createStatement();
String sqlstr="insert into student1 value('4','heuqnjie','21','男','互联网');";
st.executeUpdate(sqlstr);
System.out.println(sqlstr);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class Add {
/**
* @param args
*/
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection ct;
try {
ct = DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","hequnjie");
Statement st=ct.createStatement();
String sqlstr="insert into student1 value('4','heuqnjie','21','男','互联网');";
st.executeUpdate(sqlstr);
System.out.println(sqlstr);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}