package aa;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.*;
import java.sql.SQLException;
import java.lang.*;
public class qq {
Connection con;
Statement sta;
ResultSet rs;
String sqldriver;
String sqlurl;
String user;
String pwd;
public qq(){
sqldriver= "sun.jdbc.odbc.JdbcOdbcDriver ";
sqlurl= "jdbc:odbc:pub ";
user= "sa ";
pwd= " ";
init();
}
public void init()
{
try{
Class.forName(sqldriver);
System.out.println( "driver is ok ");
con=DriverManager.getConnection(sqlurl,user,pwd);
System.out.println( "connection is ok ");
sta=con.createStatement();
rs=sta.executeQuery( "select * from titles ");
while(rs.next())
System.out.println(rs.getDate(1));
}catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
new qq();
}
}
出现下面的错
D:\Borland\JBuilder2006\jdk1.5\bin\javaw -classpath "C:\Documents and Settings\Administrator\jbproject\aa\classes;D:\Borland\JBuilder2006\jdk1.5\jre\lib\jce.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\ext\localedata.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\ext\dnsns.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\ext\sunjce_provider.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\ext\sunpkcs11.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\deploy.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\charsets.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\plugin.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\im\thaiim.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\im\indicim.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\jsse.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\javaws.jar;D:\Borland\JBuilder2006\jdk1.5\jre\lib\rt.jar;D:\Borland\JBuilder2006\jdk1.5\sample\jnlp\servlet\jnlp.jar;D:\Borland\JBuilder2006\jdk1.5\sample\jnlp\servlet\jnlp-servlet.jar;D:\Borland\JBuilder2006\jdk1.5\sample\jnlp\servlet\jardiff.jar;D:\Borland\JBuilder2006\jdk1.5\lib\jconsole.jar;D:\Borland\JBuilder2006\jdk1.5\lib\dt.jar;D:\Borland\JBuilder2006\jdk1.5\lib\tools.jar;D:\Borland\JBuilder2006\jdk1.5\lib\htmlconverter.jar;D:\Borland\JBuilder2006\jdk1.5\demo\jfc\Java2D\Java2Demo.jar;D:\Borland\JBuilder2006\jdk1.5\demo\jfc\CodePointIM\CodePointIM.jar;D:\Borland\JBuilder2006\jdk1.5\demo\plugin\jfc\Java2D\Java2Demo.jar;D:\Borland\JBuilder2006\jdk1.5\demo\plugin\jfc\CodePointIM\CodePointIM.jar " aa.qq
driver is ok