import java.sql.*;
public class shujuku {
public shujuku() {
}
public static void main(String[] args) {
// TODO code application logic here
String JDriver="sun.jdbc.odbc.jdbcOdbcDriver";
String conURL="jdbc:odbc:TestDB";
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="creat table zg("
+"职工号 char(10),"
+"姓名 char(15),"
+"性别 char(15),"
+"工资 integer,"
+"职称 char(15)"
+")";
s.executeUpdate(query);
String r1="insert into zg values("+"'1002','张小华','男','600','助工')";
String r2="insert into zg values("+"'1007','李梨','女','1000','工程师')";
String r3="insert into zg values("+"'1001','丁为国','男','650','助工')";
String r4="insert into zg values("+"'1005','黄菊','女','1200','工程师')";
String r5="insert into zg values("+"'1003','宁涛','男','2500','高工')";
s.executeUpdate(r1);
s.executeUpdate(r2);
s.executeUpdate(r3);
s.executeUpdate(r4);
s.executeUpdate(r5);
s.close();
con.close();
}
catch(SQLException e)
{
System.out.println("SQLException:"+e.getMessage());
}
}
}
运行后:
init:
deps-jar:
Compiling 1 source file to E:\java\数据库\shujuku\build\classes
compile:
run:
ForName:sun.jdbc.odbc.jdbcOdbcDriver
SQLException:No suitable driver
生成成功(总时间:0 秒)
这个问题要怎么解决~ 急
还有我已经建立了testDB 这个数据源
如何连接数据库