Advertisement
Kyosukerui

Untitled

Jun 7th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package netbenis;
  7.  
  8. import java.sql.DriverManager;
  9. import java.sql.*;
  10. import oracle.jdbc.*;
  11. import oracle.jdbc.pool.OracleDataSource;
  12.  
  13.  
  14. /**
  15. *
  16. * @author
  17. */
  18. public class Netbenis {
  19.  
  20. /**
  21. * @param args the command line arguments
  22. */
  23. public static void main(String[] args) throws SQLException {
  24. // TODO code application logic here
  25. Connection conn=null;
  26. Statement stmt=null;
  27. try {
  28. //connessione con datasource
  29. OracleDataSource ods = new OracleDataSource();
  30. ods.setURL("jdbc:oracle:thin:@//"+"localhost:1521/xe");
  31. ods.setUser("wakemeup.jpg");
  32. ods.setPassword("Icantwakeup.jpg");
  33. conn = ods.getConnection();
  34. stmt = conn.createStatement();
  35. String sql="SELECT * " + "FROM AUTOSTRADA";
  36. ResultSet rset = stmt.executeQuery(sql);
  37. rset.next();
  38. System.out.println("query: ");
  39. // int nome=rset.getInt("Estensione");
  40. System.out.println(rset.getString(1));
  41.  
  42. } catch (SQLException e){
  43. System.out.println("Error "+e.getMessage());
  44. } finally {
  45. if (stmt != null) stmt.close();
  46. if (conn != null) conn.close();
  47. }
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement