This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Access to the Oracle database using Java Applets  RSS feed

Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ..................
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you put your code between "[ code]" and "[ /code]" without the spaces, it will be easier for us to read and understand.
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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. )
Monty Ireland
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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. )
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!