The Artima Developer Community
Sponsored Link

Java Answers Forum
Connecting to MySQL from Java JApplet

1 reply on 1 page. Most recent reply: Apr 29, 2002 5:27 AM by Pavan Kumar Keely

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Sangeetha

Posts: 1
Nickname: sangs
Registered: Apr, 2002

Connecting to MySQL from Java JApplet Posted: Apr 9, 2002 3:13 AM
Reply to this message Reply
Advertisement
Hi,

This could be a basic question.

I am trying to establish an JDBC connection to MySQL from my applet. It throws ClassNotFound Exception.

But i am able to connect to MySQL Server through Java Application.

The class path is set properly.

Below is the sample code.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import org.gjt.mm.mysql.*;

public class Test extends JApplet{

public void init(){
String DriverName = "org.gjt.mm.mysql.Driver";
String DBUrl = "jdbc:mysql://localhost/TAPTool?
user=1155&password=test123";

try {
Class.forName(DriverName).newInstance();
java.sql.Connection C = DriverManager.getConnection(DBUrl);

C.close();
}
catch (SQLException E) {
System.out.println("SQLException: " + E.getMessage());
System.out.println("SQLState: " + E.getSQLState());
System.out.println("VendorError: " + E.getErrorCode());
}
catch (ClassNotFoundException E){ System.out.println("ClassNotFound: " + E.getMessage()); }
catch (InstantiationException E) {System.out.println("SQLException: " + E.getMessage());}
catch (IllegalAccessException E) {System.out.println("SQLException: " + E.getMessage());}

}

}

Error is ClassNotFound: org.gjt.mm.mysql.Driver


Pavan Kumar Keely

Posts: 7
Nickname: pavan
Registered: Mar, 2002

Re: Connecting to MySQL from Java JApplet Posted: Apr 29, 2002 5:27 AM
Reply to this message Reply
> Hi,
>
> This could be a basic question.
>
> I am trying to establish an JDBC connection to MySQL
> from my applet. It throws ClassNotFound Exception.
>
> But i am able to connect to MySQL Server through Java
> Application.
>
> The class path is set properly.
>
> Below is the sample code.
>
> import javax.swing.*;
> import java.awt.*;
> import java.awt.event.*;
> import java.sql.*;
> import org.gjt.mm.mysql.*;
>
> public class Test extends JApplet{
>
> public void init(){
> String DriverName = "org.gjt.mm.mysql.Driver";
> String DBUrl = "jdbc:mysql://localhost/TAPTool?
> user=1155&password=test123";
>
> try {
> Class.forName(DriverName).newInstance();
> java.sql.Connection C =
> = DriverManager.getConnection(DBUrl);
>
> C.close();
> }
> catch (SQLException E) {
> System.out.println("SQLException: " +
> " + E.getMessage());
> System.out.println("SQLState: " +
> " + E.getSQLState());
> System.out.println("VendorError: " +
> " + E.getErrorCode());
> }
> catch (ClassNotFoundException E){
> System.out.println("ClassNotFound: " +
> E.getMessage()); }
> catch (InstantiationException E)
> {System.out.println("SQLException: " +
> E.getMessage());}
> catch (IllegalAccessException E)
> {System.out.println("SQLException: " +
> E.getMessage());}
>
> }
>
> }
>
> Error is ClassNotFound: org.gjt.mm.mysql.Driver

hi Sangeetha....

please include the mm mysql jar file in the archive attribute of "applet" tag. you won't get that problem....
If you feel still unclear...please feel free to mail me at keelypavan@yahoo.com

bye
Pavan Kumar Keely
Software Engineer, Quillis India

Flat View: This topic has 1 reply on 1 page
Topic: About Multidimensional Arrays Previous Topic   Next Topic Topic: equals doubt

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use