Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class Sample {
- public static void main(String args[]) {
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- ^
- <!--This is a Type 4 Driver. This implements the
- interface provided by the JDBC specification
- (java.sql.Driver)-->
- String url = "jdbc:oracle:thin:@10.184.132.128:1521:devdb";
- Connection conn = DriverManager.getConnection(url,"dev1201st","develop1201");
- Statement stmt = conn.createStatement();
- ResultSet rset = stmt.executeQuery("select sysdate from dual");
- while (rset.next()) {
- System.out.println(rset.getString(1));
- }
- }
- catch (ClassNotFoundException e)
- {
- e.printStackTrace();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement