File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Dsn Problem?