JDBC Conectivity

Discussion in 'Java' started by e01osama, May 12, 2005.

  1. e01osama

    e01osama Guest

    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....
    e01osama, May 12, 2005
    #1
    1. Advertising

  2. e01osama

    Ross Bamford Guest

    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/ + in
    Ross Bamford, May 12, 2005
    #2
    1. Advertising

  3. e01osama

    e01osama Guest

    thanks..
    e01osama, May 13, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith Wansbrough

    Re: jdbc help:sun.jdbc.odbc.JdbcOdbcDriver

    Keith Wansbrough, Aug 16, 2004, in forum: Java
    Replies:
    0
    Views:
    751
    Keith Wansbrough
    Aug 16, 2004
  2. Betty
    Replies:
    1
    Views:
    9,864
    Juha Laiho
    May 21, 2005
  3. Jesus M. Salvo Jr.
    Replies:
    2
    Views:
    4,161
    robert
    Feb 11, 2006
  4. Bruce
    Replies:
    4
    Views:
    754
    Bjorn Abelli
    Mar 25, 2006
  5. Jose

    conectivity error

    Jose, Jan 31, 2009, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    689
Loading...

Share This Page