Topic: 急,连access问题! |
Print this page |
1.急,连access问题! | Copy to clipboard |
Posted by: huangyinping Posted on: 2006-03-31 21:54 这个程序没有编译错误,而且是从书上copy下来的,在连接数据源时也是按照书上的步骤来的,但运行时总是 显示找不到数据源,到底是什么问题啊?请大家帮忙哦! import java.sql.*; public class Lianxi { public static void main(String[] args) { try { try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(ClassNotFoundException e){ System.out.println(e.getMessage()); } String url = "jdbc:odbc:driver={ Microsoft Access Driver (*.mdb)};DBQ=E:\\db1.mdb"; Connection con = DriverManager.getConnection(url, "", ""); Statement stmt = con.createStatement(); String query = "select * from user"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { String str = rs.getString("name"); System.out.println(str); } con.close(); } catch(SQLException e){ System.out.println("*********"); System.out.println("SQLException in main:"+e.getMessage()); System.out.println("**SQLState:"+e.getSQLState()); System.out.println("**SQL Error Code:"+e.getErrorCode()); System.out.println("*********"); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } 这个程序没有编译错误,而且是从书上copy下来的,在连接数据源时也是按照书上的步骤来的,但运行时总是 显示找不到数据源,到底是什么问题啊?请大家帮忙哦! |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |