/**
* 单独的java程序连接oracle数据库
* author:JavaAlpha
* date :2012-12-3 12:02:44
*/
import java.sql.*;
public class Test {
public static void main(String[] args){
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@192.168.1.1:1521:orcl";
String user = "root";
String password = "123456";
try {
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, password);
if(!conn.isClosed())
System.out.println("Succeeded connecting to the Database!");
Statement statement = conn.createStatement();
String sql = "SELECT PASSWORD from USER WHERE id='test1'";
ResultSet rs = statement.executeQuery(sql);
while(rs.next())
{
System.out.println(rs.getString("PASSWORD"));
}
rs.close();
conn.close();
} catch(ClassNotFoundException e) {
System.out.println("Sorry,can`t find the Driver!");
e.printStackTrace();
} catch(SQLException e) {
e.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
}
}
单独的java程序连接oracle数据库
原创
©著作权归作者所有:来自51CTO博客作者JavaAlpha的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:你嘴上所说的人生,就是你的人生
下一篇:爱是一种遇见!!
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
单独的java程序连接oracle数据库
/** * 单独的java程序连接oracle数据库 * author:JavaAlpha * date :2012-12-3 12:02:44 */import java.sql.*;public class Test {public static void main(String[] args){String driver = "oracle.jdbc.driver.OracleDriver";String url = "jdbc:oracle:thin:@192.168.1.1:1521:orcl";String user = &quo
sql oracle java java程序 oracle数据库 -
连接Oracle数据库
先将System.Data.OralceClient.dll文件拷贝项目目录的Bin目录下,通常位于C:/windows/Microsoft.NET/Franmework/v.1.1.4322目录中.//连接字符串string Oracle_ConnStr = "Data Source=Oracle9i;Integrated Security=yes";//创建OralceConnection对象OralceConnection Conn= new OralceConnection(Oracle_ConnStr);try{Conn.Open();Label1.Text=&q
oracle 连接字符串 oracle数据库 microsoft 文件拷贝