Two Laptop Bag
The moose likes JDBC and Relational Databases and the fly likes Access to the Oracle database using Java Applets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Access to the Oracle database using Java Applets" Watch "Access to the Oracle database using Java Applets" New topic

Access to the Oracle database using Java Applets

Bharat Agarwal

Joined: Jun 16, 2001
Posts: 21
I am trying to connect the applet with the oracle database... I have tried using all different tactics....and it is giving me different problems all the time....CAn some one help me out....
TIA. The code is as under.....
if( ==Button7)
System.out.println("Button Pressed");
// String query = "(INSERT INTO LANDMARK VALUES('null', 'null', 'null', 'null'))";

//*********************************Make connection with the database
try {
if (conn == null)
txtfield.append("Loading JDBC dirver " + "oracle.jdbc.driver.OracleDriver()" + "\n");

//Driver driver=(Driver)Class.forName("oracle.jdbc.driver.OracleDriver()").newInstance();

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
System.out.println("Registering the driver");
txtfield.append("Connecting to the database" +" jdbc racle ci8:webhiqs/donotenter@diglib1$
conn = DriverManager.getConnection ("jdbc racle:thin:@(description=(address=(host=
(port=1521))(connect_data=(sid=medbio)))", "webhiqs", "donotenter");
//Connection conn=DriverManager.getConnection("jdbc racle ci8:webhiqs/");
//Connection conn=DriverManager.getConnection("jdbc$
txtfield.append("Connected" + "\n");

System.out.println("Registering the driver");
} // if ends..................................
System.out.println("CONNECTED TO THE DATABASE");
// String query = ("INSERT INTO LANDMARK" + " VALUES('null', 'null', 'null', 'null'))";

Statement stmt = conn.createStatement();
txtfield.append("Executing query " + query + "\n");
ResultSet rset=stmt.executeQuery(query);

while (
txtfield.append(rset.getString(1) + "\n");

// if(state3.executeUpdate(query)>0)
// {
System.out.println("the followed row is inserted");
// }
// else
// {
// System.out.println("out of the if loop");
// }
// state3.close();
}catch (NoClassDefFoundError etc) {etc.printStackTrace();
} catch (SQLException se) {se.printStackTrace();
} catch (Exception e) {e.printStackTrace();} // try-catch ends......................
System.out.println("Out of try block");
txtfield.append("Out of try block ");
}//end of submit button ..................
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
If you put your code between "[ code]" and "[ /code]" without the spaces, it will be easier for us to read and understand.
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
I agree please use code /code in future posts.
More info requested
1. operating system are you using
2. what is ther version of the JDK
3. what is ther version of the JDBC
4. are you gocing to use OCI or thin client
I post code about 6 to 9 months ago please search for it...
I have been busy ... i will try to check back in a few day if you have any questions.

Multi-Platform Database Developer ( on E.S.T. )

Multi Platform Database Developer & DBA on E.S.T.
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
Working Code Example:
import java.sql.*;
public class CreateCoffees {
public static void main(String args[]) {

String url = "jdbcracle:thin:@machinename:1521:sid";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME varchar(32), " +
"SUP_ID int, " +
"PRICE float, " +
"SALES int, " +
"TOTAL int)";

Statement stmt;

try {

catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
try {
con = DriverManager.getConnectionurl, "USERID", "PASSWD");
stmt = con.createStatement();stmt.executeUpdate(createString);


} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
hope this helps...
Multi-Platform Database Developer ( on E.S.T. )
I agree. Here's the link:
subject: Access to the Oracle database using Java Applets
jQuery in Action, 3rd edition