• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Access to the Oracle database using Java Applets

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
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(evt.target ==Button7)
{
System.out.println("Button Pressed");
// String query = "(INSERT INTO LANDMARK VALUES('null', 'null', 'null', 'null'))";

//*********************************Make connection with the database
try {
txtfield.setText(null);
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");
//Class.forName("oracle.jdbc.driver.OracleDriver");
txtfield.append("Connecting to the database" +" jdbc racle ci8:webhiqs/donotenter@diglib1$
conn = DriverManager.getConnection ("jdbc racle:thin:@(description=(address=(host= diglib1.cecs.missouri.edu)(protocol=tcp)
(port=1521))(connect_data=(sid=medbio)))", "webhiqs", "donotenter");
//Connection conn=DriverManager.getConnection("jdbc racle ci8:webhiqs/donotenter@diglib1.cecs.missouri.edu:1521:medbio");
//Connection conn=DriverManager.getConnection("jdbc racle:thin:@diglib1.cecs.missouri.edu:$
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 (rset.next())
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 ..................
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Working Code Example:
<code>
import java.sql.*;
public class CreateCoffees {
public static void main(String args[]) {

String url = "jdbc:oracle: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 {
Class.forName("oracle.jdbc.driver.OracleDriver");
}

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

stmt.close();
con.close();

} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
</code>
hope this helps...
------------------
Multi-Platform Database Developer ( on E.S.T. )
reply
    Bookmark Topic Watch Topic
  • New Topic