Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data source name not found and no default driver specified

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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("jdbc:odbc: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)
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Did you create an ODBC datasource named local in windows?
 
Shyam Hai
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ("jdbc:odbc: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: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
    Bookmark Topic Watch Topic
  • New Topic