java.sql.SQLException:指定了无效的 Oracle URL
java.sql.SQLException:指定了无效的 Oracle URL
昨天晚上用MyEclipse连接Oracle,出现了“ java.sql.SQLException: 指定了无效的 Oracle URL”的错误,但是太晚了,就休息了。刚才在Google上搜索了一下,感觉自己的代码是没有问题的。
url="jdbc:oracle:thin@localhost:1521:orcl";
即格式为:jdbc:oracle:thin@IP地址:1521:数据库SID。
后来发现,我忽略了一个细节:就是在"thin"的后面也是有个冒号的!!!正确的应该是
url="jdbc:oracle:thin:@localhost:1521:orcl";
细节啊……很重要。
至于驱动的安装和我上一篇内容一致,只不过注册的是Oracle安装包下的jdbc文件夹里面的class12.jar。
附基本操作代码:
import java.sql.*;
public class OracleConnectionDemo {
private static final String DBDRIVER="oracle.jdbc.driver.OracleDriver";
private static final String DBURL="jdbc:oracle:thin:@127.0.0.1:1521:MyOracle";
private static final String DBUSER="scott";
private static final String DBPWD="xiaoxiao";
public OracleConnectionDemo()throws Exception{
Class.forName(DBDRIVER);
Connection conn=DriverManager.getConnection(DBURL,DBUSER,DBPWD);
String sql="select empno,ename,sal from emp";
PreparedStatement ps=conn.prepareStatement(sql);
//获得EMP表中的信息。
ResultSet rs=ps.executeQuery();
while(rs.next()){
String empno=rs.getString(1);
String empname=rs.getString(2);
int sal=rs.getInt(3);
System.out.println("empno :"+empno+" empname:"+empname+" sal:"+sal);
}
rs.close();
ps.close();
conn.close();
System.out.println("\nOperate Over!");
}
public static void main(String args[])throws Exception{
new OracleConnectionDemo();
}
}
java.sql.SQLException:指定了无效的 Oracle URL的更多相关文章
- [转载]“java.sql.SQLException:指定了无效的 Oracle URL”
原文地址:"java.sql.SQLException:指定了无效的 Oracle URL"作者:康愚 昨天晚上用MyEclipse连接Oracle,出现了" java. ...
- java.sql.SQLException: 关闭的连接 解决办法
程序如果长时间不进行数据库操作,那么数据源中的 Connection 很可能已经断开.其原因有可能是防火墙,或者连接的数据库设置的超时时间.这里使用的是 C3P0 连接 oracle 数据库,引起的异 ...
- oracle: jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111
https://www.cnblogs.com/mmlw/p/5808072.html org.mybatis.spring.MyBatisSystemException: nested except ...
- hibernate连接oracle12c数据库报:java.sql.SQLException: ORA-01017: 用户名/口令无效; 登录被拒绝。(用户名/口令在oracle客户端以及cmd命令都能登入)
报错信息: 2017-09-22 15:40:07,354 WARN [org.hibernate.cfg.SettingsFactory] - Could not obtain connection ...
- java.sql.SQLException: 对只转发结果集的无效操作: last
出错代码如下:static String u = "user";static String p = "psw";static String url = &quo ...
- Error querying database. Cause: java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名
今天调试程序是遇到了,下面的一个问题.我将对应的SQL语句拿到Toad下也能正常的执行,感觉有点莫名其妙,根据异常信息的提示查看对应的映射结果集也没发现错误,然后百度了一下,也有许多朋友也遇到过这样的 ...
- 在mybatis中使用存储过程报错java.sql.SQLException: ORA-06550: 第 1 行, 第 7 列: PLS-00905: 对象 USER1.HELLO_TEST 无效 ORA-06550: 第 1 行, 第 7 列:
hello_test是我的存储过程的名字,在mapper.xml文件中是这么写的 <select id="getPageByProcedure" statementType= ...
- mybatis项目报错:java.sql.SQLException: ORA-00911: 无效字符 解决方法
如果你用java写程序访问数据库,出现这个问题:java.sql.SQLException: ORA-00911: 无效字符 at oracle.jdbc.driver.DatabaseError.t ...
- java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 在指定的 DSN 中,驱动程序和应用程序之间的体系结构不匹配
今天把sql server 2008 r2装了起来,64位的,然后就迫不及待地体验连接数据库的操作,编程语言是java.我一开始学了一种非常老的连接方式,使用JDBC-ODBC桥.初次使用不太熟练,所 ...
随机推荐
- (转)awk命令
转自:http://man.lupaworld.com/content/manage/ringkee/awk.htm#id2874788 整理:Jims of 肥肥世家 <jims.yang@g ...
- Javascript:sort()方法快速实现对数组排序
定义和用法: sort() 方法用于对数组的元素进行排序. 语法: arrayObject.sort(sortby) 注释:sortby,可选,规定排序顺序,必须是函数. 说明: 如果调用该方法时没有 ...
- 数组字符串与指针字符串的区别 char s[]="***" 和char *s="***"的区别
char s[] = "wangshihui"; char *s = "wangshihui"; 皆宣告了s字符串,在C-style string的函数皆可使用 ...
- 在Ubuntu下构建Bullet以及执行Bullet的样例程序
在Ubuntu下构建Bullet以及执行Bullet的样例程序 1.找到Bullet的下载页,地址是:https://code.google.com/p/bullet/downloads/list 2 ...
- codeforces Arrival of the General 题解
A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command o ...
- Linux系统调用system_call
2016-03-25 张超的<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 我的虚拟环境和代码在http ...
- ProgressBar( 进度条) 组件
一. 加载方式 //class 加载方式<div class="easyui-progressbar"data-options="value:60" st ...
- html5 canvas画进度条
这个ie8的兼容是个问题,ie8 的innerHTML有问题啊,添加两个附件吧 <!DOCTYPE html> <html> <head> <meta cha ...
- scala学习笔记——类和对象
基础语法关于Scala程序,这是非常要注意以下几点. 区分大小写 - Scala是大小写敏感的,这意味着标识Hello 和 hello在Scala中会有不同的含义. 类名 - 对于所有的类名的第一个字 ...
- C#学习笔记之结构体
1.概述 结构是一种与类相似的数据类型,不过它较类更为轻量,一般适用于表示类似Point.Rectangle.Color的对象.基本上结构能办到的类全都能办到,但在某些情况下使用结构更为合适,后面会有 ...