I'm trying to study for a basic SQL test at school but unfortunately I copied the class that we are supposed to use into a project on my pc and I am getting the following error:

我正在尝试在学校学习基本的SQL测试,但不幸的是我将我们应该使用的类复制到我的电脑上的一个项目中,我收到以下错误:

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

java.sql.SQLException:[Microsoft] [ODBC驱动程序管理器]未找到数据源名称且未指定默认驱动程序

package Question1;

// Your name, Q 1
import java.sql.*;
import java.io.*;
import javax.swing.*;

public class GreenWood
{
 // Set up database connection
   private static final String DATABASE_FILE_NAME = "WoodDB.mdb";
   private static final String DRIVER = "jdbc:odbc:DRIVER=" +
   "{Microsoft Access Driver (*.mdb)};" +
   "DBQ=" + new File (DATABASE_FILE_NAME).getAbsolutePath ();
  static
  {
     try
     {
        Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
     }
         catch (ClassNotFoundException e)
        {
           System.out.println ("Class not found");
           e.printStackTrace ();
        }
  }


  private Connection dbcon;
  private BufferedReader keyb = new BufferedReader (new InputStreamReader (System.in));

   public GreenWood ()
  {
     System.out.println ("WoodDB Connection");
     try
     {
        dbcon = DriverManager.getConnection (DRIVER);
        Statement stmt = dbcon.createStatement ();
        System.out.println ("Connection successful\n");

        char choice = ' ';
        do
        {

         //Prints options for user input

           choice = keyb.readLine ().toUpperCase ().charAt (0);
           System.out.println (" ");
           switch (choice)
           {
             //calls query methods based on user input

           }
        }
        while (choice != 'X');
        dbcon.close ();
        System.out.println ("Done");
        Thread.sleep (1000);
        System.exit (0);
     } // try
         catch (Exception e)
        {
        // process exceptions here
           System.out.println ("Connection unsuccessful");
           e.printStackTrace ();
           System.out.println (e.toString ());
        }
  } // HoutSoorte constructor

  //Query Methods
  //Main creates new instance of GreenWood

my WoodDB database is located in the root project directory.

我的WoodDB数据库位于根项目目录中。

I Have done some troubleshooting and I believe that the problem is the URL of the driver location;

我做了一些故障排除,我相信问题是驱动程序位置的URL;

dbcon = DriverManager.getConnection (DRIVER);

DRIVER being:

驱动程序是:

private static final String DRIVER = "jdbc:odbc:DRIVER=" +
   "{Microsoft Access Driver (*.mdb)};" +
   "DBQ=" + new File (DATABASE_FILE_NAME).getAbsolutePath ();

After about an hour of research I'm still just as confused as I was. If anyone can help this nub programmer(me) by explaining the problem in baby words and how I can fix it, it would be ever appreciated.

经过大约一个小时的研究,我仍然像以前一样困惑。如果有人可以通过解释婴儿话语中的问题以及如何解决它来帮助这个nub程序员(我),那将永远受到赞赏。

3 个解决方案

#1


3

Try using 32-bit JVM. I am getting the same error message when trying to connect from 64-bit JVM.

尝试使用32位JVM。尝试从64位JVM连接时,我收到相同的错误消息。

更多相关文章

  1. 参数化的Insert语句,事务抛出错误
  2. 错误:第t列。tgisconstraint不存在
  3. 通过MySQL JDBC驱动程序(连接器/J)进行负载平衡
  4. 请问MYSQL 08S01错误怎么解决,谢谢
  5. 处理SQL标准中的错误值
  6. SQL连接“实时错误'91'”
  7. SQLException:没有适合jdbc的驱动程序:derby://localhost:1527。
  8. 连接SQLServer时提示“但是在登录前的握手期间发生错误。 (provi
  9. 无法弄清楚mySQL语法错误的来源

随机推荐

  1. 问题集录--jquery将json转excel保持
  2. jquery或js怎样让第一个ifame中的bottun
  3. jQuery图片热点链接添加编辑插件
  4. jQuery基于Canvas的微信运动折线图动态曲
  5. 如何防止jQuery Ajax请求在Internet Expl
  6. 一句实现jquery导航栏
  7. 百花齐放 日月同辉――采用JSI解决不同类
  8. 基于AdminLTE的jquery头像更新
  9. jQuery Validate 表单验证插件
  10. css3和jquery实现的可折叠导航菜单(适合