日期:2014-05-18  浏览次数:20804 次

远程连接oracle数据库的问题,百分回报!!!在线等,问题解决马上加分结帖!!!!!!!
我用的是oracle9i版本的数据库,现在需要远程连接,不知道oracle数据库要进行怎样的配置,还有连接字符串是什么?高手帮忙,本人不胜感激并以百分回报!!!!!!!!

------解决方案--------------------
没有连接过oracle数据库
不过在baidu上面应该可以搜到,
c#连接orcacle数据库的列子应该很多.
帮楼主顶一下

------解决方案--------------------
private final String driverName = "oracle.jdbc.driver.OracleDriver"; //driver name
/**url to connect {@link #driverName}*/
private String url = "jdbc:oracle:thin:@192.168.1.221:1521:yoyo";
private String user ="aaa";
;
private String password = "aaa";
------解决方案--------------------
public Connection getConnection() 
throws SQLException/*,ClassNotFoundException,java.lang.InstantiationException,java.lang.IllegalAccessException*/
{
try
{
Class.forName(driverName);//.newInstance();
return DriverManager.getConnection(url,user,password);
}
catch (ClassNotFoundException e)
{
System.out.println("加载驱动类 : " +driverName+ " 失败!");
e.printStackTrace();
throw new SQLException("没有找到驱动类");
}
catch (SQLException e){
System.out.println("连接数据库失败");
e.printStackTrace();
throw e;
}/*
catch (java.lang.InstantiationException e){
System.out.println("实例化驱动程序失败");
throw new SQLException("实例化驱动程序失败");
}
catch (java.lang.IllegalAccessException e){
System.out.println("实例化驱动程序失败");
throw new SQLException("实例化驱动程序失败");
}*/
catch (Exception e){
throw new SQLException("其它异常");
}
//return conn;
}
------解决方案--------------------
http://bbs.doughty.cn/BrowersP.aspx?QID=3669
------解决方案--------------------
string connectString = "user id=[帐号];password=[密码];data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=[协议:默认tcp])(HOST=[主机地址])(PORT=[端口:默认1521]))(CONNECT_DATA=(SERVICE_NAME=[服务名称])))";
------解决方案--------------------
示例:

string connectString = "user id=scott;password=tiger;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sfd)))";