数据库系统为MySQL,ip:59.78.154.233 port:3306数据库名称studentDB。 请用JSP连接数据库,创建一个表:student, 表有两个字段,id :整数型name:字符串(你的姓名)。并增加一条记录(id为你的学号,name为你的名字)
Class.forName("com.mysql.jdbc.Driver");//加载数据库驱动
Connection conn = DriverManager.getConnection("jdbc:mysql://59.78.154.233:3306/studentDB","student","123456");//获得数据库连接对象
Statement stat = conn.createStatement();//获取Statement对象以便操纵数据库
String sql_createTabel = "create table student( id int primary key,name char(10) )";
stat.executeUpdate(sql_createTable);//建表
string sql_insert = "insert into student values('140153813',高琛贵)";
stat.executeUpdate(sql_insert);//插入数据