package DB;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class OracleTest {
/**
* @param args
* @throws ClassNotFoundException
*/
public static void main(String[] args) {
String url="jdbc:oracle:thin:@localhost:1521:ORCL";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection(url, "scott", "admin");
Statement stmt=conn.createStatement();
String strsql="select USERNAME,PASSWORD from USERTABLE";
ResultSet rs=stmt.executeQuery(strsql);
while(rs.next())
{
System.out.println("用户名:"+rs.getString(1));
System.out.println("密码:"+rs.getString(2));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class OracleTest {
/**
* @param args
* @throws ClassNotFoundException
*/
public static void main(String[] args) {
String url="jdbc:oracle:thin:@localhost:1521:ORCL";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection(url, "scott", "admin");
Statement stmt=conn.createStatement();
String strsql="select USERNAME,PASSWORD from USERTABLE";
ResultSet rs=stmt.executeQuery(strsql);
while(rs.next())
{
System.out.println("用户名:"+rs.getString(1));
System.out.println("密码:"+rs.getString(2));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}