Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JDBC Conectivity

Reply
Thread Tools

JDBC Conectivity

 
 
e01osama
Guest
Posts: n/a
 
      05-12-2005
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*dbcracleci:@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....

 
Reply With Quote
 
 
 
 
Ross Bamford
Guest
Posts: n/a
 
      05-12-2005
On Wed, 2005-05-11 at 20:29 -0700, e01osama wrote:

>
> 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

--
[Ross A. Bamford] [ross AT the.website.domain]
Roscopeco Open Tech ++ Open Source + Java + Apache + CMF
http://www.roscopec0.f9.co.uk/ + http://www.velocityreviews.com/forums/(E-Mail Removed)in


 
Reply With Quote
 
 
 
 
e01osama
Guest
Posts: n/a
 
      05-13-2005
thanks..

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limited or no conectivity carts69 General Computer Support 2 12-26-2009 06:11 AM
conectivity error Jose ASP .Net Web Services 0 01-31-2009 07:53 PM
conectivity problem Li'l Roberto Wireless Networking 3 11-30-2004 11:36 PM
Re: jdbc help:sun.jdbc.odbc.JdbcOdbcDriver Keith Wansbrough Java 0 08-16-2004 07:31 PM
Router conectivity problem Sid Computer Support 1 02-08-2004 05:28 PM



Advertisments