java.sql.SQLException: ORA-03115: 不支持的网络数据类型或表示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14302577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.sql.SQLException: ORA-03115: unsupported network datatype or representation
提问by ajay
I'm Using Oracle 11g database. When i try to access data from db it was showing the error java.sql.SQLException: ORA-03115: unsupported network datatype or representation. I'm not understanding what this error means..
我正在使用 Oracle 11g 数据库。当我尝试从 db 访问数据时,它显示错误 java.sql.SQLException: ORA-03115: unsupported network datatype or representation。我不明白这个错误是什么意思..
my code is :
我的代码是:
String uname,pass;
ResultSet rs = null;
response.setContentType("text/html");
PrintWriter out=response.getWriter();
try
{
uname=request.getParameter("uname");
pass=request.getParameter("pass");
Connection con=prepareConnection();
String Query="select uname from passmanager where pass=?";
PreparedStatement ps=con.prepareStatement(Query);
ps.setString(1,pass);
rs=ps.executeQuery(Query);
if (rs.next() && uname.equalsIgnoreCase(rs.getString("uname")) || uname.equalsIgnoreCase(rs.getString("email"))) {
HttpSession session = request.getSession(true);
session.setAttribute("uname", rs.getString(1));
ServletContext context = getServletContext();
RequestDispatcher dispatcher = context
.getRequestDispatcher("/profile");
dispatcher.forward(request, response);
}
Any one help me to solve this problem..
任何人都可以帮我解决这个问题..
回答by Codo
Instead of:
代替:
rs = ps.executeQuery(Query);
you should execute:
你应该执行:
rs = ps.executeQuery();
Otherwise, you unprepareyour statement and lose all parameters because you assign it a new SQL statement (even though it's the same).
否则,您将没有准备好您的语句并丢失所有参数,因为您为其分配了一个新的 SQL 语句(即使它是相同的)。
回答by igr
Add email column
添加电子邮件列
select uname, email from passmanager where pass=?
回答by robertovg
This error appears when you try to get a field by name ( rs.getString("uname") in your case) which is not in the resultset.
当您尝试按名称(在您的情况下为 rs.getString("uname"))获取不在结果集中的字段时,会出现此错误。
And like igr said, you are trying to get the email field ( with rs.getString("email") ) and it's not in the query, so this is your error.
就像 igr 所说的,您正在尝试获取电子邮件字段(使用 rs.getString("email") )并且它不在查询中,所以这是您的错误。
I found this conversation because I was getting the same error in an application when I was trying to get a field with an whitespace at the end of the string ( rs.getString("uname ") instead of rs.getString("uname" ).
我找到了这个对话,因为当我尝试获取字符串末尾带有空格的字段( rs.getString("uname ") 而不是 rs.getString("uname" )时,我在应用程序中遇到了相同的错误.
And I just fix it using the correct name for the field I was getting from the query.
我只是使用我从查询中获得的字段的正确名称来修复它。
I hope it is useful! ;)
我希望它有用!;)