Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author Jiří
- */
- public class OracleConnection1 {
- public static void main(String[] args) throws ClassNotFoundException, SQLException {
- String userName = "st25412";
- String password = "st25412";
- Connection connection = null;
- Statement statement = null;
- ResultSet resultSet = null;
- Class c = Class.forName("oracle.jdbc.OracleDriver");
- System.out.println("Load driver class: " + c);
- connection = DriverManager.getConnection("jdbc:oracle:thin:@sql101.upceucebny.cz:1521:oracle10", userName, password);
- // connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", userName, password);
- connection.setAutoCommit(true);
- statement = connection.createStatement();
- resultSet = statement.executeQuery("select id, nazev, rokstartu, stat from serialy order by id");
- while (resultSet.next())
- System.out.println(resultSet.getString(1) + ". " + resultSet.getString(2) + "(" + resultSet.getString(3) + ")");
- resultSet.close();
- statement.close();
- connection.close();
- }
- }
Add Comment
Please, Sign In to add comment