File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes URL error (DSN not found) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "URL error (DSN not found)" Watch "URL error (DSN not found)" New topic

URL error (DSN not found)

Ajay Chauhan

Joined: Dec 10, 2003
Posts: 5
Hi! all.....
i am facing a problem while executing the following code.The program runs fine if i give DSN variable as....
String dsn = "jdbc dbc:Test";
but when i try to give my DSN variable by attaching my machine ip address to it in the following manner an error results..
String dsn = "jdbc dbc://";
i m connecting to an MS Access database with dsn name as 'Test' configured thru Data Sources(ODBC) in control panel.....and by now u must have understood that i want to connect to my database from a different machine in the LAN....pls. help me.
the error is:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(
at sun.jdbc.odbc.JdbcOdbc.standardError(
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(
at sun.jdbc.odbc.JdbcOdbcDriver.connect(
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at Dbase.main(
the code is:
import java.sql.*;
import java.util.*;
import sun.jdbc.odbc.*;
class Dbase
public static void main(String[] args)
Connect inst_Connect = new Connect();
catch (Exception ee1)
class Connect
void Ajay()
// Load the JDBC-ODBC bridge driver
catch( ClassNotFoundException ee)
void select() throws SQLException
// ODBC data source name
Connection con;
System.out.println("1 \n");
String dsn = "jdbc dbc://";
//String dsn = "jdbc dbc:Test";
String user = "";
String password = "";
// Connect to the database
con = DriverManager.getConnection(dsn, user, password);
System.out.println("2 \n");
// Shut off autocommit
Statement stmt; // SQL statement object
String query; // SQL select string
ResultSet rs; // SQL query results
boolean more; // "more rows found" switch
String v2; // Temporary storage results
Vector results = new Vector( 10 );
query = "SELECT FirstName, LastName " + "FROM StudentInfo ";
stmt = con.createStatement();
rs = stmt.executeQuery(query);
// Check to see if any rows were read
more =;
if (!more)
System.out.println("No rows found.");
// Loop through the rows retrieved from the query
while (more)
v2 = "Name: " + rs.getString("FirstName") + " " + rs.getString("LastName");
System.out.println( v2 );
results.addElement( v2 + "\n" );
more =;
catch( Exception ee)
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 62761

Welcome to the Ranch 'Zombie UOR'!
You'll find this forum a great place to seek help on JDBC, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
JDBC/JSP Forum Bartender

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: URL error (DSN not found)