Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package netbenis;
- import java.sql.DriverManager;
- import java.sql.*;
- import oracle.jdbc.*;
- import oracle.jdbc.pool.OracleDataSource;
- /**
- *
- * @author
- */
- public class Netbenis {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws SQLException {
- // TODO code application logic here
- Connection conn=null;
- Statement stmt=null;
- try {
- //connessione con datasource
- OracleDataSource ods = new OracleDataSource();
- ods.setURL("jdbc:oracle:thin:@//"+"localhost:1521/xe");
- ods.setUser("wakemeup.jpg");
- ods.setPassword("Icantwakeup.jpg");
- conn = ods.getConnection();
- stmt = conn.createStatement();
- String sql="SELECT * " + "FROM AUTOSTRADA";
- ResultSet rset = stmt.executeQuery(sql);
- rset.next();
- System.out.println("query: ");
- // int nome=rset.getInt("Estensione");
- System.out.println(rset.getString(1));
- } catch (SQLException e){
- System.out.println("Error "+e.getMessage());
- } finally {
- if (stmt != null) stmt.close();
- if (conn != null) conn.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement