package connection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class ConnectionAccess {
public static void main(String[] args) {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:employee","","");
Statement stmt =con.createStatement();
ResultSet rs =stmt.executeQuery("select fname,minit from employee");
while (rs.next()){
System.out.print("\t fname:"+rs.getString(1));
System.out.print("\t minit:"+rs.getString(2));
System.out.println();
}
rs.close();
stmt.close();
con.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
posted on 2006-08-22 13:07
摩西 阅读(720)
评论(1) 编辑 收藏