问题描述
环境:--win7,Oracle11g,java1.5.0_19,Lomboz_Eclipse3.2;--在SqlPlus环境下,可以通过:用户名scott/密码tiger登陆;--可以通过“https://localhost:1158/em”方式登陆界面并使用system账户登陆--已通过AddExternalArchives添加“ojdbc5.jar”包问题程序:importjava.sql.*;publicclassTextJDBC{publicstaticvoidmain(String[]args)throwsException{Class.forName("oracle.jdbc.driver.OracleDriver");//neworacle.jdbc.driver.OracleDriver();Connectioncon=DriverManager.getConnection("jdbc:oracle:thin:@http://localhost:1158:abc","scott","tiger");}}
错误:Exceptioninthread"main"java.sql.SQLException:Invalidconnectionstringformat,avalidformatis:"host:port:sid"atoracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)atoracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)atoracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)atoracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)atoracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)atjava.sql.DriverManager.getConnection(UnknownSource)atjava.sql.DriverManager.getConnection(UnknownSource)atTextJDBC.main(TextJDBC.java:9)Causedby:oracle.net.ns.NetException:Invalidconnectionstringformat,avalidformatis:"host:port:sid"atoracle.net.resolver.AddrResolution.resolveSimple(AddrResolution.java:472)atoracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:397)atoracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:672)atoracle.net.ns.NSProtocol.connect(NSProtocol.java:237)atoracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042)atoracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301)...7more===============================================================================================================在下刚刚开始学习数据库的东西,这问题搜了半天也没找到。厚颜请大家帮我看一看吧。
解决方案
本帖最后由 moon197896 于 2010-05-31 22:12:01 编辑
解决方案二:
("jdbc:oracle:thin:@localhost:1558:abc");
解决方案三:
引用1楼focusforce的回复:
("jdbc:oracle:thin:@localhost:1558:abc");
Connectioncon=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1158:abc","scott","tiger");
解决方案四:
不用http://的Connectioncon=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1158:abc","scott","tiger");
解决方案五:
引用3楼gulang76的回复:
不用http://的Connectioncon=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1158:abc","scott","tiger");
同意楼上的
解决方案六:
Connectioncon=DriverManager.getConnection("jdbc:oracle:thin:@http://localhost:1158:abc","scott","tiger");url写错了
解决方案七:
不用http://
解决方案八:
UP可恶的字数
解决方案九:
学习了jf~
解决方案十:
谢谢楼上几位,但是问题还是有“Connectioncon=DriverManager.getConnection("jdbc:oracle:thin:@http://localhost:1158:abc","scott","tiger");”这段代码我已经替换成“Connectioncon=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1158:abc","scott","tiger");”和“Connectioncon=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.4:1158:abc","scott","tiger");”----“192.168.1.4”是我本机的IP地址,这个地址配置给了一个无线网卡,目前我通过这个无线网卡上网,另外还有一个禁用的网卡,没有分配地址。这样仍然无法通过。还请大家不吝赐教啊
解决方案十一:
Class.forName(driverClass);conn=DriverManager.getConnection(url,username,password);其中的参数如下:driverClassoracle.jdbc.driver.OracleDriverurljdbc:oracle:thin:@127.0.0.1:1521:orcl
解决方案十二:
引用10楼wbl_dragon的回复:
Class.forName(driverClass);conn=DriverManager.getConnection(url,username,password);其中的参数如下:driverClassoracle.jdbc.driver.OracleDriverurljdbc:oracle:thin:@127.0.0.1:1521:orcl
en