java - How to resolve [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified -


i tried make connection access encountered following problem after compiling java file

[microsoft][odbc driver manager] data source name not found , no default driver specified

my code :

import java.sql.*;  public class abc            {             public static void main(string args[])             {               try                  {                  class.forname("sun.jdbc.odbc.jdbcodbcdriver");                  string fn="c:/ctb/new";                  string database = "jdbc:odbc:driver={microsoft access driver                 (*.mdb,*.accdb)};dbq="+fn+".accdb;";                  connection conn = drivermanager.getconnection(database);           system.out.println(conn);                    }             catch(exception e)                  {                   e.printstacktrace();                   system.out.println("error!");                  }            }      } 

when copy , paste code eclipse error message mention. because driver name malformed. instead of...

string database = "jdbc:odbc:driver={microsoft access driver                 (*.mdb,*.accdb)};dbq="+fn+".accdb;"; 

...you need use...

string database = "jdbc:odbc:driver={microsoft access driver (*.mdb, *.accdb)};dbq="+fn+".accdb;"; 

note single spaces in ... driver (*.mdb, *.accdb)...


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -