これは、jdbcとsqlを使用してデータベースに2つのテーブルを作成する簡単なプログラムです。私はエラーが私はマーク/ エラーライン /からであることがわかりキャッチblock.onさらなる調査から「SQLエラー」を取得するコードを実行する上MYSQL JDBCエラー
Connection con=null;
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/","root","root");
try
{
Statement st=con.createStatement();
st.executeUpdate("CREATE DATABASE IF NOT EXISTS ARCPAGE");
st.executeUpdate("USE ARCPAGE");
st.executeUpdate("CREATE TABLE IF NOT EXISTS User(user_id integer NOT NULL AUTO_INCREMENT,user_name varchar(20) NOT NULL,user_pass varchar(20) NOT NULL,PRIMARY KEY (user_id))");
st.executeUpdate("CREATE TABLE IF NOT EXISTS Usermap(user_name varchar(20) NOT NULL,role_name varchar(20) NOT NULL)");
ResultSet res=st.executeQuery("SELECT * FROM USER");
res.next();
ResultSet resmap=st.executeQuery("SELECT * FROM USERMAP WHERE USER_NAME='"+res.getString("user_name")+"'");
/*error line */ res.next();
resmap=st.executeQuery("SELECT * FROM USERMAP WHERE USER_NAME='"+res.getString("user_name")+"'");
}
catch(SQLException e)
{
System.out.println("SQL ERROR");
}
}
catch(Exception e)
{
System.out.println("ERROR");
}
。私は間違って何をしていますか?
e.printstacktrace上-krishan
()
java.sql.SQLException: Operation not allowed after ResultSet closed
at com.mysql.jdbc.ResultSet.checkClosed(ResultSet.java:652)
at com.mysql.jdbc.ResultSet.next(ResultSet.java:5942)
at trees.TreeBean.<init>(TreeBean.java:51)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:184)
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:98)
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:405)
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:265)
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:191)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:73)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:71)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69)
at org.apache.el.parser.AstValue.getValue(AstValue.java:112)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:106)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
at javax.faces.component.UIOutput.getValue(UIOutput.java:164)
at org.primefaces.util.ComponentUtils.getStringValueToRender(ComponentUtils.java:61)
at org.primefaces.component.inputtext.InputTextRenderer.encodeMarkup(InputTextRenderer.java:86)
at org.primefaces.component.inputtext.InputTextRenderer.encodeEnd(InputTextRenderer.java:53)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:308)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:181)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:125)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:164)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at org.primefaces.component.tabview.TabViewRenderer.encodeContents(TabViewRenderer.java:180)
at org.primefaces.component.tabview.TabViewRenderer.encodeMarkup(TabViewRenderer.java:120)
at org.primefaces.component.tabview.TabViewRenderer.encodeEnd(TabViewRenderer.java:61)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
例外ハンドラで 'e.printStackTrace()'を呼び出し、ここに結果を貼り付けてください。 –
例外ブロックで、スタックトレース - e.printStackTrace()を印刷して詳細を表示します。 – isobar
はスタックトレースを追加しました – DanMatlin