myeclipse裡面導入新的項目
右鍵>import>General>existing...>next>select root >browse>項目>finish
導jar包
右鍵>properties>java build path >libraries>ojdbc14-10.2.0.3.jar
獲取本機ip地址cmd>ipconfig
ipv4的地址為自己的地址
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@127.0.0.1:1521:xe";
String user = "scott";
String password="tiger";
Connection conn = DriverManager.getConnection(url,user,password);
PreparedStatement pstam = conn.prepareStatement("select * from userinfo ");
ResultSet rs = pstam.executeQuery();
while(rs.next()){
System.out.println(rs.getInt("id")+rs.getString("name")+rs.getInt("age"));
}
pstam.close();
conn.close();