Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Dsn Problem?

 
harsh garg
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using the JDBC-ODBC bridge with MySQL? Would it not just be easier to use a type 4 driver?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic