wood burning stoves 2.0*
The moose likes JDBC and the fly likes File Dsn Problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "File Dsn Problem?" Watch "File Dsn Problem?" New topic
Author

File Dsn Problem?

harsh garg
Ranch Hand

Joined: Jul 13, 2008
Posts: 33
import java.sql.*;
public class dsn
{

public static void main(String[] args)
{
Connection con;
Statement st;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("Jdbc:Odbc:ex");
System.out.print("Connection Successful");
}
catch(Exception e)
{
System.out.println(e);
}

}
}


The file DSN was set up using the xp ODBC administrator and it is in the default location of:

C:\ProgramFiles\CommonFiles\ODBC\DataSources

and is called "ex.dsn" - it looks like this
[ODBC]
DRIVER=MySQL ODBC 5.1 Driver
UID=root
PORT=3306
DATABASE=harsh
SERVER=localhost

This is error message,how i solve it?
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Why are you using the JDBC-ODBC bridge with MySQL? Would it not just be easier to use a type 4 driver?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
jQuery in Action, 2nd edition
 
subject: File Dsn Problem?
 
Similar Threads
connectivity between java and ms access
JDBC connectivity problem through JSP
Regarding Servlet connectivity with ms-access
cannot access ms access database after loading servlet to tomcat
Connecting to MSSQL2000