java.sql.SQLException: [Microsoft][ODBC驱动程序管理器]未发现数据源名称且未指定默认驱动程序-求指点
packagecom.salarymanage.dbconn;importjava.sql.*;publicclassTest{privateStringurl;priv...
package com.salarymanage.dbconn;
import java.sql.*;
public class Test {
private String url;
private Connection con=null;
public Test() throws ClassNotFoundException,SQLException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//url="jdbc:odbc:Driver={ Microsoft Access Driver(*.mdb,*.accdb)};" +"DBQ=D:\\Workspace\\SalaryManage\\studentM.mdb";
//url="jdbc:odbc:Driver={ Microsoft Access Driver(*.mdb,*.accdb);DBQ=D:/Workspace/SalaryManage/studentM.mdb}";
String path="D://Workspace//SalaryManage//studentM.mdb";
url="jdbc:odbc:driver={Microsoft Access Driver(*.mdb)};DBQ="+path;
//url="jdbc:odbc:driver={ Microsoft Access Driver (*.mdb);DBQ=d:\\db\\typhnoon}";
System.out.println("ok");
con=DriverManager.getConnection(url);
System.out.println("o11");
}
public static void main(String[] args)
{
try {new Test();
} catch (Exception e)
{
e.printStackTrace();
}
}
}
报
java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3073)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at com.salarymanage.dbconn.Test.<init>(Test.java:19)
at com.salarymanage.dbconn.Test.main(Test.java:25) 展开
import java.sql.*;
public class Test {
private String url;
private Connection con=null;
public Test() throws ClassNotFoundException,SQLException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//url="jdbc:odbc:Driver={ Microsoft Access Driver(*.mdb,*.accdb)};" +"DBQ=D:\\Workspace\\SalaryManage\\studentM.mdb";
//url="jdbc:odbc:Driver={ Microsoft Access Driver(*.mdb,*.accdb);DBQ=D:/Workspace/SalaryManage/studentM.mdb}";
String path="D://Workspace//SalaryManage//studentM.mdb";
url="jdbc:odbc:driver={Microsoft Access Driver(*.mdb)};DBQ="+path;
//url="jdbc:odbc:driver={ Microsoft Access Driver (*.mdb);DBQ=d:\\db\\typhnoon}";
System.out.println("ok");
con=DriverManager.getConnection(url);
System.out.println("o11");
}
public static void main(String[] args)
{
try {new Test();
} catch (Exception e)
{
e.printStackTrace();
}
}
}
报
java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3073)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at com.salarymanage.dbconn.Test.<init>(Test.java:19)
at com.salarymanage.dbconn.Test.main(Test.java:25) 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询