JDBC Conectivity

E

e01osama

hi,
I have installed Oracle 9i, then create a database, fine,
I wrote a java programe to connect databade. it also working...
here is the programe
==============================­==============================­====


import java.sql.*;


class Display
{
public static void main(String args[])
{
Connection con;
try
{
try
{
DriverManager.registerDriver(n­ew
oracle.jdbc.driver.OracleDrive­r());
con =
DriverManager.getConnection("j­dbc:eek:racle:eek:ci:mad:IFS","sys
as sysdba","abc123");


System.out.println("Connection is
succes....");


CallableStatement proce =
con.prepareCall("{call insert_()}");
System.out.println("Call insert ....");
proce.executeUpdate();
}
catch (SQLException sqlex)
{
System.out.println("SQL
exception"+sqlex);
}
}
catch (Exception e)
{
System.out.println("Unknown Exception"+e);
}
}



}


==============================­==============================­===========


this will insert vales to test table. now i want to run select query
from the test table.
I dont know how to do that.....


help me....
 
R

Ross Bamford

this will insert vales to test table. now i want to run select query
from the test table.
I dont know how to do that.....


help me....

e.g:


// ---

String someSql = "SELECT field FROM table"
Statement s;
ResultSet res;
try {
s = con.createStatement();
if (s.execute(someSql)) {
res = s.getResultSet();

while (res.next()) {
System.out.println("Field value is: "+res.getString("field"));
}
} catch (SQLException e) {
System.out.println("Oops!");
} finally {
try {
res.close();
s.close();
} catch (Exception e) { /* ignore */ }
}

// ---

Hope that helps,
Ross
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top