xuebing
发贴: 5
积分: 0
|
于 2004-09-24 14:57
程序如下: import java.sql.*;
public class JDBCTest{ public static void main(String args[]){ String url="jdbc:odbc:company"; String user="sa"; String password="sa"; String ls_1="select * from employee"; try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection(url,user,password); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery(ls_1); System.out.print("firstname "); System.out.print("lastname "); System.out.print("age "); System.out.print("address "); System.out.print("city "); while(rs.next()){ System.out.print(rs.getString(1)+"|"); System.out.print(rs.getString(2)+"|"); System.out.print(rs.getInt(3)+"|"); System.out.print(rs.getString(4)+"|"); System.out.println(rs.getString(5)); } rs.close(); stmt.close(); con.close(); } catch(SQLException sqle){ System.out.println(1+sqle.toString()); } catch(Exception e){ System.out.println(2+e.toString()); } } } 运行结果:1java.sql.SQLException:[Micr0soft][ODBC驱动程序管理器]未发现数据源名称并且未指定默认驱动程序
是什么原因?
|