Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can applet connect to firebird database ?

843807Jul 27 2006 — edited Jul 28 2006
I have been trying to connect firebird database using applet for web application . Here are my code :

import java.applet.*;
// required to paint on screen
import java.awt.*;
import java.sql.*;
import java.util.*;


// the start of an applet - HelloWorld will be the executable class
// Extends applet means that you will build the code on the standard Applet class
public class AppletJDBC extends Applet
{
private Connection connection;
private String message = "Initializing";
public String string1;
public String string2;
public String stringErr;

// The method that will be automatically called when the applet is started
public void init()
{
stringErr = "No Err";
// It is required but does not need anything.
String JDBCDRIVER = "org.firebirdsql.jdbc.FBDriver";
String URLHEADER = "jdbc:firebirdsql:";
String DB_IP = "127.0.0.1";
String PORTVALUE = "/3050:";
String DB_NAME= "D:/JDBCSampleProject/JDBCSample/HALIMFB.gdb";
String URL;

String USERNAME = "username";
String PASSWD = "password";

try{

string1 = "a";
URL = URLHEADER + DB_IP + PORTVALUE + DB_NAME;
// Look up the JDBC driver by class name. When the class loads, it
// automatically registers itself with the DriverManager used in
// the next step.
Class driver = Class.forName(JDBCDRIVER);

Connection con = DriverManager.getConnection(URL, USERNAME, PASSWD);
Statement stat = con.createStatement();


String selStat = "Select * from EMPLOYEE";
ResultSet rs = stat.executeQuery(selStat);

while (rs.next()) {
String s = rs.getString("ID");
String n = rs.getString("NAME");
String t = rs.getString("TEL");
String text = s + " " + n+" "+t;
}

stat.close();
con.close();

}catch (Exception ex){
stringErr = ex.toString();
}

string2 = "b";


}


public void stop()
{
// no actions needed here now.
}



public void paint(Graphics g)
{

g.drawString(string1,20,20);
g.drawString(stringErr,20,40);
g.drawString(string2,20,60);
g.drawString("Hellooow World",20,80);

}


}

The error show s that it couldnt find JDBC clas Driver. I have already included the driver. what else do i need to do ? thanks

Message was edited by:
Btreksun
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 24 2006
Added on Jul 27 2006
1 comment
239 views