Home > Database > Mysql Tutorial > java连接access数据库出现问题

java连接access数据库出现问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:36:34
Original
1189 people have browsed it

package p1;import java.sql.*;public class t4 {public static void main(String[] args){ Connection con; Statement sql; ResultSet rs; try{ Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); } catch(ClassNotFoundException e) { System.out.println(+e)

 

package p1;
import java.sql.*;
public class t4 {
public static void main(String[] args)
{
 Connection con;
 Statement sql;
 ResultSet rs;
 try{
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 }
 catch(ClassNotFoundException e)
 {
  System.out.println(""+e);
 }
 try
 {
  con=DriverManager.getConnection("jdbc:odbc:match","","");
  sql=con.createStatement();
  rs=sql.executeQuery("SELECT * FROM 星座");
  while(rs.next())
  {
   String s=rs.getString(1);
   System.out.println(s);
  }
  con.close();
 }
 catch(SQLException e){System.out.println(e);}
}
}
Copy after login

运行后提示: java.sql.SQLException: [Microsoft][ODBC Microsoft Access 驱动程序] 不能打开数据库 '(未知的)'。应用程序可能无法识别该数据库,或文件可能损坏。

我在网上查了说是2007的驱动要去下载,我下载好了也安好了,还是不行。各位高手帮下小弟。

我的是access 2007,我建立一个名字为Match的数据库,格式为*.accdb,里面有一个名字为 星座 的表,数据源为match,数据库也注册好了。

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template