怎么写java程序,来实现创建一个连接去连接本地的Oracle数据库中的某一张表,谁能写一个例子啊!求教
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Oracle {
public static void main(String[] args) throws SQLException,
ClassNotFoundException {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@127.0.0.1:1521:test";
String user = "test";
String password = "test";
Connection conn = DriverManager.getConnection(url, user, password);
PreparedStatement ps = conn.prepareStatement("select * from emp");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
System.out.println(rs.getObject(1));
}
rs.close();
ps.close();
conn.close();
}
}
String url = "jdbc:oracle:thin:@127.0.0.1:1521:test"; 能不能详细分解一下这句话,里面的thin是神马? test是神马?
thin是连接的方式,test是你的数据库,就是sid