java连接orcal出错
package com.shi.oracle;
import java.sql.*;
public class testOrcaleCrud {
public void main(String[] args){
//定义变量
Connection ct=null;
PreparedStatement ps=null;
ResultSet rs=null;
try{
//加载驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
//得到连接
ct=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl","system","123");
//创建Preparedstatment的接口对象
ps=ct.prepareStatement("select * from emp");
System.out.println(ps);
//完成查询
rs=ps.executeQuery();
//循环输出
while(rs.next()){
System.out.println(rs.getString("ename"));
}
}catch(Exception e){}
finally{
//关闭资源
if(rs!=null){
try{
rs.close();
}
catch(SQLException e){e.printStackTrace();}
rs=null;
}
if(ps!=null){
try{
ps.close();
}
catch(SQLException e){e.printStackTrace();}
ps=null;}
if(ct!=null){
try{
ct.close();
}
catch(SQLException e){e.printStackTrace();}
ct=null;
}
}
}
}
全是这样的错
testing oracle-character-set-1 against <abc>
PASSED LOSSY
testing oracle-character-set-1 against <ab?c>
PASSED LOSSY
怎么解决?
[解决办法]
ding
java不会
[解决办法]
oracle thin driver这个驱动正确吗?
oracle的监听好使吗?测试通过先!
[解决办法]
看看对应的数据库驱动版本是否匹配
[解决办法]
ct=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl","system","123");
这句改成
ct=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521/orcl","system","123");
试试?1521后面的:换成/
[解决办法]
莫非是字符集的问题?