Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: NEWBIE H.E.L.P java 1.2 to oracle database Connection
/**
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:@machine ip:1521:oracle service name Connection con =
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:
> > 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 - 05:39:07 CDT
![]() |
![]() |