Thursday, November 25, 2010

SQL-JAVA

import java.io.*;
import java.sql.*;

public class sql{
public static void main(String args[]) throws ClassNotFoundException,SQLException
{
Class.forName("oracle.jdbc.OracleDriver") ;
      System.out.println("Oracle JDBC driver loaded ok.");

      Connection con = DriverManager.getConnection(
        "jdbc:oracle:thin:cs359/cs359@192.168.1.198:1521:orcl");
      System.out.println("Connected with @192.168.1.198:1521:orcl");

    con.setAutoCommit(false);
    Statement stmt = con.createStatement();
    ResultSet rset =null;
        rset = stmt.executeQuery("select * from emp");
    while (rset.next())
         System.out.println (rset.getString(1));
    rset.close();
    stmt.close();
    System.out.println ("Ok.");
  }
}

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Betway Casino Site – All your favourite games from Microgaming
    Betway casino luckyclub site, also called Betway, is a trusted online casino with a great range of games. This is why Betway is one of the best casinos in

    ReplyDelete

FOLLOWERS