package jdbc;
import java.sql.*;
public class Example10_1 {
public static void main(String[] args)
{
//声明jdbc驱动程序对象
String JDriver ="sun.jdbc.odbc.Jdbc.JdbcOdbcDriver";
//定义JDBc的URL的对象,Testdb为数据源
String conURL="jdbc:odbc:weimeijun";
try
{
Class.forName(JDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.out.println("ForName"+e.getMessage());
}
try{
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
String query="create table student6("+"学号 char(10),"+"姓名 char(15),"+"分数 integer"+")";//创建表
/*
String a="insert into student6 values("+"'141360231','魏',20)";
String b="insert into student6 values("+"'141360232','沈',20)";
String c="insert into student6 values("+"'141360233','郭',20)";
String d="insert into student6 values("+"'141360234','田',20)";
String e="insert into student6 values("+"'141360235','许',20)";
String f="insert into student6 values("+"'141360236','孟',20)";
String g="insert into student6 values("+"'141360231','陈',20)";
String h="insert into student6 values("+"'141360231','柘',20)";
s.executeUpdate(query);
s.executeUpdate(a);
s.executeUpdate(b);
s.executeUpdate(c);
s.executeUpdate(d);
s.executeUpdate(e);
s.executeUpdate(f);
s.executeUpdate(g);
s.executeUpdate(h);
*/
String h1="insert into weidianlun6 values("+"'1413','柘',22)";
s.executeUpdate(h1);
s.close();
con.close();
}
catch(SQLException e1)
{
System.out.println("SQLException:"+e1.getMessage());
}
}
}