Link to home
Start Free TrialLog in
Avatar of rahul_ashish
rahul_ashish

asked on

Connecting to MYSQL

HI
I have a database in MySQL but i don't know know how to connect to MySQL. i want know, do i need a separate driver to connect to MySQL from java or the java ODBC will connect me to MySQL. if i need a separate driver then from where can i get that.
Avatar of coreyit
coreyit

A good mysql driver is available at:
  http://mmmysql.sourceforge.net/

A sample connection:
  Connection conn = null;
  try {
    DriverManager.registerDriver( new org.gjt.mm.mysql.Driver() );
    conn = DriverManager.getConnection( "jdbc:mysql://" + DBserverName + ":" + DBport + "/" + DBName + "?user=" + DBuser + "&password=" + DBpassword );
  }
  catch( SQLException e ) {
    System.out.println( "argh!" );
  }

-corey
ASKER CERTIFIED SOLUTION
Avatar of jose_tijo
jose_tijo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> do i need a separate driver to connect to MySQL from java

yes - you need to download MySQL JDBC driver
Avatar of rahul_ashish

ASKER

For Jose


Did u download any 8.jar file for that except one from SourceForge.net
For Jose


Did u download any *.jar file for that except one from SourceForge.net
Thanks for the help
I'm curious about a couple things:
1. did my suggestion not work?
2. since jose_tijo answered your question thoroughly, why does he only receive a "b"?

-corey
Hi

  I downloaded only the driver from sourceforge.net. Nothing else.

Tijo Jose
hey what is the port number for connecting to the MySQL?
hey what is the port number for connecting to the MySQL?
hey what is the port number for connecting to the MySQL?