package com.jdbc.odbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class jdbc_demo1 {
public static void main(String[] args) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection ct = DriverManager.getConnection("jdbc:odbc:mytest","scott","tiger"); //mytest为数据源名称
Statement st = ct.createStatement();
ResultSet rs = st.executeQuery("select * from emp");
while(rs.next()){
System.out.println("用户名:"+rs.getString(2));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
posted on 2011-09-26 21:55
Java_liyadong 阅读(184)
评论(0) 编辑 收藏