package com.cn;
import java.sql.*;
public class TestOracle {
/**
* @param args
*/
static Connection conn;
static Statement stm;
static ResultSet rs;
static String driver="oracle.jdbc.driver.OracleDriver";
static String url="jdbc:oracle:thin:@192.168.1.104:1521:ORCL";
public static void main(String[] args) {
try {
Class.forName(driver);
Connection ct = DriverManager.getConnection(url, "sys as sysdba", "123");
stm = ct.createStatement();
rs = stm.executeQuery("select * from emp");
while(rs.next())
{
System.out.println("用户名:"+rs.getString(2));
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.sql.*;
public class TestOracle {
/**
* @param args
*/
static Connection conn;
static Statement stm;
static ResultSet rs;
static String driver="oracle.jdbc.driver.OracleDriver";
static String url="jdbc:oracle:thin:@192.168.1.104:1521:ORCL";
public static void main(String[] args) {
try {
Class.forName(driver);
Connection ct = DriverManager.getConnection(url, "sys as sysdba", "123");
stm = ct.createStatement();
rs = stm.executeQuery("select * from emp");
while(rs.next())
{
System.out.println("用户名:"+rs.getString(2));
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}