java光标位置无效_ResultSet.getString(1)引发java.sql.SQLException:当前光标位置的无效操作...

当我运行以下servlet时:

// package projectcodes;

public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException {

String UserID = request.getParameter("UserID");

String UserPassword = request.getParameter("UserPassword");

String userName = null;

String Email = null;

Encrypter encrypter = new Encrypter();

String hashedPassword = null;

try {

hashedPassword = encrypter.hashPassword(UserPassword);

Context context = new InitialContext();

DataSource ds = (DataSource)context.lookup("java:comp/env/jdbc/photog");

Connection connection = ds.getConnection();

String sqlStatement = "SELECT email,firstname FROM registrationinformation WHERE password='" + hashedPassword + "'";

PreparedStatement statement = connection.prepareStatement(sqlStatement);

ResultSet set = statement.executeQuery();

userName = set.getString(1); // <

response.sendRedirect("portfolio_one.jsp");

// userName = set.getString("FirstName");

Email = set.getString(3);

if(set.wasNull() || Email.compareTo(UserID) != 0) {

// turn to the error page

response.sendRedirect("LoginFailure.jsp");

} else {

// start the session and take to his homepage

HttpSession session = request.getSession();

session.setAttribute("UserName", userName);

session.setMaxInactiveInterval(900); // If the request doesn't come withing 900 seconds the server will invalidate the session

RequestDispatcher rd = request.getRequestDispatcher("portfolio_one.jsp");

rd.forward(request, response); // forward to the user home-page

}

}catch(Exception exc) {

System.out.println(exc);

}

我得到以下异常:

INFO: java.sql.SQLException: Invalid operation at current cursor position.

at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)

at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)

at org.apache.derby.client.am.ResultSet.getString(Unknown Source)

at com.sun.gjc.spi.base.ResultSetWrapper.getString(ResultSetWrapper.java:155)

-----> at projectcodes.ValidateDataForSignIn.doPost(ValidateDataForSignIn.java:28

at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)

at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)

at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)

at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)

at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)

at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)

at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)

at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

at java.lang.Thread.run(Thread.java:722)

Caused by: org.apache.derby.client.am.SqlException: Invalid operation at current cursor position.

at org.apache.derby.client.am.ResultSet.checkForValidCursorPosition(Unknown Source)

at org.apache.derby.client.am.ResultSet.checkGetterPreconditions(Unknown Source)

... 30 more

服务器上面的日志显示,行号28是导致异常的原因。但是我无法得到例外的原因。表中的所有列的数据类型均为varchar。

我已在Servlet代码中突出显示了行号28 (根据服务器日志的异常原因) 。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/543193.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python web服务器 apache_Windows下搭建Apache+Django+Python Web服务环境

最近在学Django&#xff0c;想用Apache搭建一个服务器环境&#xff0c;因此在网上看了好多资料&#xff0c;很多都是用Python2.6和Apache2.2搭建的环境&#xff0c;不过我还是想用Python35和Apache24来搭建&#xff0c;具体环境如下&#xff1a; 参考资料&#xff1a; Apache配…

Python_List对象内置方法详解

前言 在上一篇中介绍了Python的序列和String类型的内置方法&#xff0c;本篇继续学习作为序列类型成员之一的List类型的内置方法。 软件环境 系统 UbuntuKylin 14.04软件 Python 2.7.3IPython 4.0.0列表List 列表是一种容器&#xff0c;存放内存对象的引用。即是任意内存对象的…

java删除javaee_JavaEE--集合--删除List中指定元素

一、Java 循环删除list中指定元素增强for循环删除指定元素Testpublic void test(){String[] strs{"a", "b", "c", "f", "b", "e", "d"};Listlist new ArrayList<>(Arrays.asList(strs));for (St…

无法从传输连接中读取数据:远程主机强迫_电力远程抄表中的应用

系统概述锐谷智联无线传输终端设备DT7710S&#xff0c;实现远程抄表应用。系统构成通过使用DT7710S&#xff0c;实现电表、水表等数据实时向中心传输。供应商可以通过数据中心的快速读取数据节省人力和时间。项目描述工业自动化的发展&#xff0c;远程抄表已成为智能电网系统中…

python定义变量名的时候、需要注意问题_python中将函数赋值给变量时需要注意的一些问题...

前言 本文主要给大家介绍的是关于python将函数赋值给变量时需要注意的一些问题&#xff0c;分享出来供大家参考学习&#xff0c;下面话不多说了&#xff0c;来一起看看详细的介绍&#xff1a; 见过两种函数赋值给变量的形式&#xff0c;一种是 af 另一种是 af() 这两种形式是有…

vmware nat模式网络不通_【EVENG入门】 03EVENG网络运行环境(桥接模式、NAT模式、Cloud连接虚拟设备)...

EEmulated&#xff0c;模拟VVirtual&#xff0c;虚拟EEnvironment&#xff0c;环境NNext&#xff0c;下一个GGeneration&#xff0c;一代也就是EVE-NG下一代模拟器虚拟环境当然&#xff0c;EVE也是黄昏&#xff0c;NG就是女鬼了EVE-NG黄昏的女鬼演示视频在此操作文档在此以下是…

金融行业 | 电子银行系统性能优化解决方案

随着互联网金融的蓬勃发展&#xff0c;以及来自支付宝等新兴网络金融机构的强大冲击&#xff0c;传统银行业纷纷加大对手机银行和网络银行等电子银行业务的投入力度&#xff0c;用户也从网银时代的足不出户转账付款发展到今天随时随地通过手机获取各种金融服务&#xff0c;前端…

python安装gz文件_python tar.gz怎么安装-问答-阿里云开发者社区-阿里云

Windows环境&#xff1a; 安装whl包&#xff1a;pip install wheel -> pip install **.whl 下载whl文件 MySQL_python-1.2.5-cp27-none-win32.whl MySQL_python-1.2.5-cp27-none-win_amd64.whl 执行pip install MySQL_python-1.2.5-cp27-none-win32.whl 如果是安装64位的&am…

Erlang/Elixir 社区摘要: 2016-05-21

Elixir 雷达, 49期 https://app.rdstation.com.br/mail/336031fa-3fe3-4d59-b05b-a86f8affa7c9如何使用环境变量来配置Exrm发布的应用 http://blog.plataformatec.com.br/2016/05/how-to-config-environment-variables-with-elixir-and-exrm/Merkle Trees in Elixir Merkle Tre…

git master主分支_Git分支管理策略及简单操作

前几天整理了一下之前项目的开发代码&#xff0c;当时使用了Git来进行代码版本管理。虽然本人熟悉常用的Git操作&#xff0c;但是对分支的管理经验非常欠缺。拿这个项目来说&#xff0c;在项目中有不下20个分支&#xff0c;每个分支间的继承关系相当之混乱&#xff0c;非常不利…

PAT (Advanced Level) 1038. Recover the Smallest Number (30)

注意前导零的消去。 #include <iostream> #include <string> #include <sstream> #include <algorithm> using namespace std;string s[1000010]; int n;bool cmp(const string &a, const string &b) {return ab<ba; }int main() {cin>&…

java在什么环境变量_Java-环境变量

很多同学不太明白环境变量的到底是什么具体有什么用? 这里阿风为不太明白的同学介绍一下.首先我们打开环境变量的位置.,这里以win10系统作为介绍在桌面邮件属性,如下然后点击高级系统变量接着点击环境变量然后你就能看到环境变量的具体设置界面了如图所示,环境变量分为用户变量…

git rebase用法_Git入门实战

如果给所有软件列出一个排行榜的话&#xff0c;那么Git定会名列前茅。Git对于代码项目的管理是具有划时代意义的&#xff0c;向Linus致敬&#xff0c;不但写出了可以与Windows争锋的Linux系统&#xff0c;还设计实现了如此强大的版本管理工具。当我了解Git后&#xff0c;真后悔…

linux md5 加密字符串和文件方法

linux md5 加密字符串和文件方法 MD5算法常常被用来验证网络文件传输的完整性&#xff0c;防止文件被人篡改。MD5全称是报文摘要算法&#xff08;Message-Digest Algorithm 5&#xff09;&#xff0c;此算法对任意长度的信息逐位进行计算&#xff0c;产生一个二进制长度为128位…

【无私分享:从入门到精通ASP.NET MVC】从0开始,一起搭框架、做项目(5.5) 登录功能的实现,完善登录功能...

索引 【无私分享&#xff1a;从入门到精通ASP.NET MVC】从0开始&#xff0c;一起搭框架、做项目 目录索引 简述 今天我们来完善我们的登录功能 项目准备 我们用的工具是&#xff1a;VS 2013 SqlServer 2012 IIS7.5 希望大家对ASP.NET MVC有一个初步的理解&#xff0c;理论性的…

jsonobject转list集合_怎样优雅的操作集合,CollectionUtils工具类正确使用姿势

点击上方"码之初"关注&#xff0c;选择"设为星标"与精品技术文章不期而遇来源&#xff1a;cnblogs.com/qdhxhz/p/10787130.html这篇讲的CollectionUtils工具类是在apache下的, 而不是springframework下的CollectionUtils。个人觉得CollectionUtils在真实项…

docx命令运行Java_使用Java将DOC文件转换为DOCX

7 个答案:答案 0 :(得分&#xff1a;3)// Open a document.Document doc new Document("input.doc");// Save document.doc.save("output.docx");请查看这在您的方案中是否有帮助。披露&#xff1a;我在Aspose担任开发人员传播者。答案 1 :(得分&#xff…

[c#基础]使用抽象工厂实现三层

引言 昨天加了一天班&#xff0c;今天闲来无事&#xff0c;就在想如何将之前的三层和最近一直在学的设计模式给联系在一起&#xff0c;然后就动手弄了个下面的小demo。 项目结构 项目各个层实现 Wolfy.Model层中有一个抽象类BaseModel.cs&#xff0c;User.cs是用户实体类&#…

php 当前ip_php获取本机ip(远程IP地址)

例子&#xff0c;php获取用户IP地址。复制代码 代码示例:// 111111111111echo $_SERVER[REMOTE_ADDR];// 2222222222222function get_local_ip() {$preg "/\A((([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.){3}(([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25…

场效应管原理_场效应管——不就是一个电控开关?

管在mpn中&#xff0c;它的长相和我们常面讲的三极管非常像&#xff0c;所以有不少修朋友好长时间还分不清楚&#xff0c;统一的把这些长相相同的三极管、场效应管、双二极管、还有各种稳压IC统统称作“三个脚的管管”&#xff0c;呵呵&#xff0c;如果这样麻木不分的话&#x…