import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class SqlTest {
public static void main(String[] args){
try{
Class.forName("sun.jdbc.odbc.JdbcodbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:studentDatabase");
Statement s=c.createStatement();
s.executeUpdate("create table 学生成绩(" +
"学号 char(10) primary key," +
"姓名 char(20)," +
"成绩 decimal(5,2) check(成绩>=0 and 成绩<=100)");
s.close();
c.close();
System.out.println("创建数据库表:学生成绩");
}
catch(Exception e){
System.err.println("异常"+e.getMessage());
}
}
}是不是先要建个 “学生成绩” 的数据库 啊 数据库路径学要给出吗 ?
还有 是不是还要安装odbc ?希望大家指点下
import java.sql.DriverManager;
import java.sql.Statement;
public class SqlTest {
public static void main(String[] args){
try{
Class.forName("sun.jdbc.odbc.JdbcodbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:studentDatabase");
Statement s=c.createStatement();
s.executeUpdate("create table 学生成绩(" +
"学号 char(10) primary key," +
"姓名 char(20)," +
"成绩 decimal(5,2) check(成绩>=0 and 成绩<=100)");
s.close();
c.close();
System.out.println("创建数据库表:学生成绩");
}
catch(Exception e){
System.err.println("异常"+e.getMessage());
}
}
}是不是先要建个 “学生成绩” 的数据库 啊 数据库路径学要给出吗 ?
还有 是不是还要安装odbc ?希望大家指点下
studentDatabase就是你连的数据库啊?连access数据库好长时间没试过了,你可以用mysql之类的!
帮你顶啊 !!