SHARE
TWEET

Untitled

a guest Dec 13th, 2016 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package aufgabe3;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. import java.sql.Statement;
  7. import java.sql.ResultSet;
  8.  
  9. public class DBconnect {
  10.    public static void main(String[] args){
  11.       final String DBNAME = "test";
  12.       final String URL = "jdbc:oracle:thin:@localhost:1521:oracle";
  13.       final String USER = "KUBE";
  14.       final String PASSWORD = "chris1711";
  15.       final String DRIVER = "com.oracle.jdbc.Driver";
  16.      
  17.       try{
  18.       Connection con = DriverManager.getConnection( URL, USER, PASSWORD );
  19.      
  20.       Statement stmt = con.createStatement();
  21.       String SQL = "SELECT * FROM aoldata.querydata";
  22.       ResultSet rs = stmt.executeQuery(SQL);
  23.       int i = 0;
  24.       while(rs.next()&&i<10){
  25.       int id = rs.getInt("ID");
  26.       String query = rs.getString("QUERY");
  27.       String clickurl = rs.getString("CLICKURL");
  28.      
  29.       System.out.println(id +" | "+ query + "| " + clickurl);
  30.       i++;
  31.       }
  32.       }catch(SQLException err){
  33.          System.out.println(err.getMessage());
  34.       }  
  35.    }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top