连接ORACLE数据库时候的错误提示 url不正确贴出你取connection的代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 strURL ="jdbc:oracle:thin:@localhost:1521:"+strServerName; try { Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); conn =DriverManager.getConnection(strURL,strUserName,strPassword); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); } 一、jsp连接Oracle8/8i/9i数据库(用thin模式) testoracle.jsp如下: <%Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl为你的数据库的SID String user="scott"; String password="tiger"; Connection conn= DriverManager.getConnection(url,user,password); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); <%rs.close(); stmt.close(); conn.close(); %二、jsp连接Sql Server7.0/2000数据库 testsqlserver.jsp如下: <%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs"; //pubs为你的数据库的 String user="sa"; String password=""; Connection conn= DriverManager.getConnection(url,user,password); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 三、jsp连接DB2数据库 <%Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance(); String url="jdbc:db2://localhost:5000/sample"; //sample为你的数据库名 String user="admin"; String password=""; Connection conn= DriverManager.getConnection(url,user,password); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 四、jsp连接Informix数据库 testinformix.jsp如下: <%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%> <html> <body> <%Class.forName("com.informix.jdbc.IfxDriver").newInstance(); String url = "jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver; user=testuser;password=testpassword"; //testDB为你的数据库名 Connection conn= DriverManager.getConnection(url); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 五、jsp连接Sybase数据库 <%Class.forName("com.sybase.jdbc.SybDriver").newInstance(); String url =" jdbc:sybase:Tds:localhost:5007/tsdata"; //tsdata为你的数据库名 Properties sysProps = System.getProperties(); SysProps.put("user","userid"); SysProps.put("password","user_password"); Connection conn= DriverManager.getConnection(url, SysProps); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); </html> 六、jsp连接MySQL数据库 <%Class.forName("org.gjt.mm.mysql.Driver").newInstance(); String url ="jdbc:mysql://localhost/softforum?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1" //testDB为你的数据库名 Connection conn= DriverManager.getConnection(url); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 七、jsp连接PostgreSQL数据库 <%Class.forName("org.postgresql.Driver").newInstance(); String url ="jdbc:postgresql://localhost/soft" //soft为你的数据库名 String user="myuser"; String password="mypassword"; Connection conn= DriverManager.getConnection(url,user,password); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 同意楼上的。connection con=DriverManager.GetConnection(string,string)第一个string 是到数据库的连接地址第二个string 是用户名和密码。 可能是没插网线,前两天我也遇到了,Oracle数据库在本机,把网线拔了,也出这个错误! 你确定一下,用sql*plus可以连接数据库 呵呵,网线当然有的,sql*plus连数据库也是正常的,我这个错误不止一台机子上有的,我试了3台机器,都是报同样的错误! alemjann(裸睡) ( ) 信誉:100 2003-04-30 11:08:00 得分:0 可能是没插网线,前两天我也遇到了,Oracle数据库在本机,把网线拔了,也出这个错误! ---------------------------------我也遇到过,当网线掉了的时候即使是在本地也会报错 API文档相关 急急急急急 序列化问题 抛出InvalidClassException和其他好多异常 关于JTable的问题 用JAVA怎么实现同https服务器通信?(附源码) 怎样得到tomcat的安装路径? 超菜问题:如何把int类型的数据转换成String类型? 请问怎样把JAVA APPLET 装载到HTML中啊! 如何用java读取windows系统日志? 关于awt中JFileChooser的几个技术点 八皇后算法问题 调查一下。 关于JTable的单元的编辑问题!
try
{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
conn =DriverManager.getConnection(strURL,strUserName,strPassword);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
}
testoracle.jsp如下: <%Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
//orcl为你的数据库的SID
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); <%rs.close();
stmt.close();
conn.close();
%二、jsp连接Sql Server7.0/2000数据库
testsqlserver.jsp如下: <%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
//pubs为你的数据库的
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
三、jsp连接DB2数据库 <%Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
String url="jdbc:db2://localhost:5000/sample";
//sample为你的数据库名
String user="admin";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
四、jsp连接Informix数据库
testinformix.jsp如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url =
"jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword";
//testDB为你的数据库名
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
五、jsp连接Sybase数据库
<%Class.forName("com.sybase.jdbc.SybDriver").newInstance();
String url =" jdbc:sybase:Tds:localhost:5007/tsdata";
//tsdata为你的数据库名
Properties sysProps = System.getProperties();
SysProps.put("user","userid");
SysProps.put("password","user_password");
Connection conn= DriverManager.getConnection(url, SysProps);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); </html>
六、jsp连接MySQL数据库
<%Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/softforum?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
//testDB为你的数据库名
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
七、jsp连接PostgreSQL数据库
<%Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql://localhost/soft"
//soft为你的数据库名
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
connection con=DriverManager.GetConnection(string,string)
第一个string 是到数据库的连接地址
第二个string 是用户名和密码。
可能是没插网线,前两天我也遇到了,Oracle数据库在本机,把网线拔了,也出这个错误!
---------------------------------
我也遇到过,当网线掉了的时候即使是在本地也会报错