Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

JDBC connect code

  Asked By: Annie    Date: Mar 10    Category: Java    Views: 1092
  


I want to connect to the MySQL and Oracle 8 personal via net work but i dont
have the code for that I know that if I want to connect to any DB use this

try {
Class.forName("myDriver.ClassName");
}
catch (java.lang.ClassNotFoundException e)
{
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

Then

conn = DriverManager.getConnection(url,userid,userpassword);

then I use conn for do the other operation but what I should write in
MyDriver.ClassName ???? and from where I can get it ??

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Sebastien Anderson     Answered On: Mar 10

You need to provide the fully-qualified class  name for the driver you want to
use. For example, there is a good driver
for mysql  at http://mmmysql.sourceforge.net/ . If you download that driver then
you would have to replace
"myDriver.ClassName" with "org.gjt.mm.mysql.Driver". I don't know what the
driver for Oracle is called though...check
the documentation for Oracle.

 
Didn't find what you were looking for? Find more on JDBC connect code Or get search suggestion and latest updates.




Tagged: