This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

Data source name not found and no default driver specified

 
Shyam Hai
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator



I create very simple program with JDBC.


package code.sample;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;

public class DemoJDBC {
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbcdbc:local","smsiss","smsiss");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT country_cd FROM country_code");

while(rs.next())
{
String one = rs.getString("country_cd");
System.out.println(one);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

When i run this program that time i get this exception.

Exception-
---------------------------

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3074)
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:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at code.sample.DemoJDBC.main(DemoJDBC.java:15)
 
Jan Cumps
Bartender
Posts: 2577
11
C++ Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Did you create an ODBC datasource named local in windows?
 
Shyam Hai
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
hai
No i am not create local.
now changed the Data Source name: dBASE Files.

Now i got Exception:
java.sql.SQLException: [Microsoft][ODBC dBase Driver] The Microsoft Jet database engine could not find the object 'data_provider'. Make sure the object exists and that you spell its name and the path name correctly.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)
at code.sample.DemoJDBC.main(DemoJDBC.java:15)
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
You need to configure the data source in ODBC before you can access the database. Failing which you are going to see those exceptions
 
Amulya Gupta
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
hello...
help needed!!
i want to use SQL10g as my backend and want to have jdbc connection...
code is:

import java.sql.*; // imports the JDBC core package
public class jdbc{
public static void main(String args[]){
String Dname;
String Location;
// SQL Query string
String query = "SELECT dname,loc FROM dept;";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // load the JDBC driver
Connection con = DriverManager.getConnection ("jdbcdbc:Inventory");
// get a connection
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query); // execute query
while (rs.next()) { // parse the results
Dname = rs.getString("dname");
Location = rs.getString("loc");
System.out.println(Dname+", "+Location);
}
con.close();
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
e.printStackTrace();
}
}
}

but when i run the error is

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


please help me...if you could tell me how to configure ODBC data source it will be really nice of you!!!
 
Jan Cumps
Bartender
Posts: 2577
11
C++ Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
if you could tell me how to configure ODBC data source it will be really nice of you!!!
http://tinyurl.com/mtwtdk
 
Mark Darwin Nacionales
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
I know the post was years ago but I felt like answering the question for those who are just experiencing this right now. It took me a while to know the answer to the question so here's the solution:

http://wiki.netbeans.org/FaqSettingHeapSize

Follow the "Running the 32-bit JVM".

All you have to do is find the netbeans.conf in the installation folder of your netbeans and change the directory from something like this:

netbeans_jdkhome="C:\Program Files\Java\jdk1.6.0_24"

to this:

netbeans_jdkhome="C:\Program Files (x86)\Java\jdk1.6.0_21"

The problem is netbeans might be running in 64 bit but MS Access only support 32-bit. So doing this would hopefully solve the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic