java.sql.SQLException: You cannot commit during a managed transaction!

Oracle Community | 3004 | 1 decade ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    java.sql.SQLException: No value specified for parameter 1解决办法_IT知识问答_希赛网

    educity.cn | 2 years ago
    java.sql.SQLException: No value specified for parameter 1 代码如下 public boolean login(UserInfo user)throws Exception{ //用户登录 boolean flag=false; int userNo=Integer.parseInt(user.getUserNo()); String password=user.getPassword(); //测试是否从现在的user对象中取到了值 System.out.println(userNo+"我是USER对象的userNo"); System.out.println(password+"我是USER对象的password"); DatabaseConnection dbc=new DatabaseConnection();//取得数据库连接和关闭对象; try{ String sql="SELECT userNo FROM userInfo where userNo= and password= "; this.conn=dbc.getConnection(); this.pst=conn.prepareStatement(sql); //this.pst.setInt(1, userNo);//给sql中参数赋值 this.pst.setLong(1, userNo); this.pst.setString(2, password); ResultSet rs=pst.executeQuery(); if(rs.next()){//传入用户账号和对应的密码都存在时为真 flag=true; System.out.println(rs.getString(userNo)+"我是从数据库里取出来的"); System.out.print(flag+"测试flag");//测试flag,看是否进入了if里面,true则进入了 rs.close(); } }catch(Exception e){ e.printStackTrace(); }finally{ if(this.pst!=null){ this.pst.close(); } this.conn.close(); } return flag; } 报的错误信息如:
  2. 0

    java.sql.SQLException: No suitable driver - Toolbox for IT Groups

    ittoolbox.com | 8 months ago
    java.sql.SQLException: No suitable driver at java.sql.DriverManager.getConnection(DriverManager .java:545) at java.sql.DriverManager.getConnection(DriverManager .java:171) at com.stc.sql.framework.jdbc.DBConnectionFactory.cre ateConnection(DBConnectionFactory.java:372) at com.stc.sql.framework.jdbc.DBConnectionFactory.get Connection(DBConnectionFactory.java:281) at com.stc.etl.engine.impl.SimpleTask.getConnection(S impleTask.java:254) at com.stc.etl.engine.impl.Extractor.getSelectData(Ex tractor.java:376) at com.stc.etl.engine.impl.Extractor.process(Extracto r.java:190) at com.stc.etl.engine.impl.ETLTaskThread.run(ETLTaskT hread.java:147)
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    1 more error - Java Programming Help - KnowCoding.com

    knowcoding.com | 2 years ago
    java.sql.SQLException: Protocol violation at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179) at oracle.jdbc.dbaccess.DBError.check_error(DBError.j ava:1160) at oracle.jdbc.ttc7.Ocommoncall.receive(Ocommoncall.j ava:149) at oracle.jdbc.ttc7.TTC7Protocol.rollback(TTC7Protoco l.java:488) at oracle.jdbc.driver.OracleConnection.rollback(Oracl eConnection.java:1412) at net.sf.hibernate.transaction.JDBCTransaction.rollb ack(JDBCTransaction.java:86) at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:90) at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:59) at com.azure.spark.database.hibernate.util.HibernateU til.get(HibernateUtil.java:569) at com.azure.spark.database.hibernate.util.HibernateS ession.get(HibernateSession.java:340) at com.azure.spark.taskcontroller.TaskControllerCompo nent.taskCompleted(TaskControllerComponent.java:11 54) at com.azure.spark.taskcontroller.TaskControllerCompo nent.onTaskEvent(TaskControllerComponent.java:1111 ) at com.azure.spark.taskcontroller.tasks.AbstractTaskC omponent.run(AbstractTaskComponent.java:354)
  5. 0

    " Protocol violation" Error in java application

    javaprogrammingforums.com | 1 year ago
    java.sql.SQLException: Protocol violation at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179) at oracle.jdbc.dbaccess.DBError.check_error(DBError.j ava:1160) at oracle.jdbc.ttc7.Ocommoncall.receive(Ocommoncall.j ava:149) at oracle.jdbc.ttc7.TTC7Protocol.rollback(TTC7Protoco l.java:488) at oracle.jdbc.driver.OracleConnection.rollback(Oracl eConnection.java:1412) at net.sf.hibernate.transaction.JDBCTransaction.rollb ack(JDBCTransaction.java:86) at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:90) at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:59) at com.azure.spark.database.hibernate.util.HibernateU til.get(HibernateUtil.java:569) at com.azure.spark.database.hibernate.util.HibernateS ession.get(HibernateSession.java:340) at com.azure.spark.taskcontroller.TaskControllerCompo nent.taskCompleted(TaskControllerComponent.java:11 54) at com.azure.spark.taskcontroller.TaskControllerCompo nent.onTaskEvent(TaskControllerComponent.java:1111 ) at com.azure.spark.taskcontroller.tasks.AbstractTaskC omponent.run(AbstractTaskComponent.java:354)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.sql.SQLException

      You cannot commit during a managed transaction!

      at samples.j2ee.ejb.CarBean.edit()
    2. samples.j2ee.ejb
      CarBean.edit
      1. samples.j2ee.ejb.CarBean.edit(CarBean.java:61)
      1 frame
    3. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      1 frame
    4. JBoss Application Server Server
      StatelessSessionContainer$ContainerInterceptor.invoke
      1. org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:629)
      1 frame
    5. JBoss Application Server Connector
      CachedConnectionInterceptor.invoke
      1. org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      1 frame
    6. JBoss Application Server Server
      Container.invoke
      1. org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
      2. org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      3. org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
      4. org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
      5. org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
      6. org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      7. org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      8. org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
      9. org.jboss.ejb.Container.invoke(Container.java:674)
      9 frames
    7. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      1 frame
    8. org.jboss.mx
      ReflectedMBeanDispatcher.invoke
      1. org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      1 frame
    9. JBoss Application Server J2SE
      MBeanServerImpl.invoke
      1. org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
      1 frame
    10. JBoss Application Server Server
      ClientContainer.invoke
      1. org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
      2. org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:83)
      3. org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      4. org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
      5. org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
      6. org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
      6 frames
    11. Unknown
      $Proxy45.edit
      1. $Proxy45.edit(Unknown Source)
      1 frame
    12. org.apache.jsp
      Save_jsp._jspService
      1. org.apache.jsp.Save_jsp._jspService(Save_jsp.java:69)
      1 frame
    13. GWT dev
      HttpJspBase.service
      1. org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
      1 frame
    14. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      1 frame
    15. GWT dev
      JspServlet.service
      1. org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
      2. org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      3. org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      3 frames
    16. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      1 frame
    17. Glassfish Core
      ContainerBase.invoke
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      3. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
      4. org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      5. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      6. org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      7. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      8. org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      9. org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      10. org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      11. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      12. org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      13. org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
      14. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      15. org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      16. org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
      17. org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      18. org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      19. org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      20. org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
      21. org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      22. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      23. org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      24. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      25. org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      26. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      27. org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      27 frames
    18. org.apache.coyote
      CoyoteAdapter.service
      1. org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
      1 frame
    19. Grizzly HTTP
      TcpWorkerThread.runIt
      1. org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
      2. org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
      3. org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
      3 frames
    20. Tomcat Util
      ThreadPool$ControlRunnable.run
      1. org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
      1 frame
    21. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:479)
      1 frame