Re: NEWBIE H.E.L.P java 1.2 to oracle database Connection

From: Enrique Ortiz <eortizto_at_danonees.danone.com>
Date: Thu, 05 Aug 1999 12:39:07 +0200
Message-ID: <37A969CB.9A10AD65_at_danonees.danone.com>


/**

  • Creates an jdbc connection to oracle

 needs  

 import java.sql.*;
 and classes.zip in the classpath,classes zip is the oracle jdbc driver, installed by oracle 8 or dowloaded from tcchnet  */
public void createJdbcConnection()
{

	try
	{
		DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

// open a conectio to the database
//jdbc:oracle:thin:_at_machine ip:1521:oracle service name Connection con =

DriverManager.getConnection("jdbc:oracle:thin:_at_10.150.2.3:1521:DWHP", user , password );
		Statement smt = con.createStatement();

// these sql returns information in the resulset
ResultSet rs = smt.executeQuery("SELECT * FROM DISCOS"); while (rs.next()) { // we list the first field of the resultset System.out.println(rs.getString(1)); }
// these sql does not return data
Statement smt2 = con.createStatement(); int num = smt2.executeUpdate("INSERT INTO DISCOS (AUTOR ) value ('brian eno')");
// returns the number of rows affected by the sql
con.close(); } catch (Exception e) { System.out.println("error !!!!"); }

}

Richard Cuello wrote:

> 
[Quoted] > I'm a newbie.
> Anyone know how connect Java 1.2 to the Oracle 8 Personal database or
> Oracle 8i? I want to be able to insert, create, etc...  using the DOS
> prompt and the java compiler.
Received on Thu Aug 05 1999 - 12:39:07 CEST

Original text of this message