用java进行对数据表的插入操作,一直提示该语句没有返回结果集
澳门博彩导航网址
澳门博彩导航网址
当前位置 : 澳门博彩导航网址 > 澳门博彩导航

用java进行对数据表的插入操作,一直提示该语句没有返回结果集

String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    String dbURL = "jdbc:sqlserver://localhost;integratedSecurity=true;Database=txtEditor";
    Statement stmt = null;
    ResultSet result = null;
    Connection dbConn = null;
    try {
                    stmt=dbConn.createStatement;
                } catch SQLException e1 {
                    // TODO Auto-generated catch block
                    e1.printStackTrace;
                }
                String strsql=editor.getText;
                java.sql.Date currentDate = new java.sql.DateSystem.currentTimeMillis;
                System.out.printlncurrentDate;
                 String sql="SET NOCOUNT ON insert into txt time,txt values "+currentDate+","+strsql+";";
                 try {
                    result = stmt.executeQuerysql;
                } catch SQLException e {
                    // TODO Auto-generated catch block
                    e.printStackTrace;
                }

com.microsoft.sqlserver.jdbc.SQLServerException: 该语句没有返回结果集。

at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverErrorSQLServerException.java:190
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatementSQLServerStatement.java:807
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecuteSQLServerStatement.java:696
at com.microsoft.sqlserver.jdbc.TDSCommand.executeIOBuffer.java:5696
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommandSQLServerConnection.java:1716
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommandSQLServerStatement.java:180
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatementSQLServerStatement.java:155
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuerySQLServerStatement.java:623
at Editor.Editor$2.actionPerformedEditor.java:228
at javax.swing.AbstractButton.fireActionPerformedUnknown Source
at javax.swing.AbstractButton$Handler.actionPerformedUnknown Source
at javax.swing.DefaultButtonModel.fireActionPerformedUnknown Source
at javax.swing.DefaultButtonModel.setPressedUnknown Source
at javax.swing.plaf.basic.BasicButtonListener.mouseReleasedUnknown Source
at java.awt.Component.processMouseEventUnknown Source
at javax.swing.JComponent.processMouseEventUnknown Source
at java.awt.Component.processEventUnknown Source
at java.awt.Container.processEventUnknown Source
at java.awt.Component.dispatchEventImplUnknown Source
at java.awt.Container.dispatchEventImplUnknown Source
at java.awt.Component.dispatchEventUnknown Source
at java.awt.LightweightDispatcher.retargetMouseEventUnknown Source
at java.awt.LightweightDispatcher.processMouseEventUnknown Source
at java.awt.LightweightDispatcher.dispatchEventUnknown Source
at java.awt.Container.dispatchEventImplUnknown Source
at java.awt.Window.dispatchEventImplUnknown Source
at java.awt.Component.dispatchEventUnknown Source
at java.awt.EventQueue.dispatchEventImplUnknown Source
at java.awt.EventQueue.access$500Unknown Source
at java.awt.EventQueue$3.runUnknown Source
at java.awt.EventQueue$3.runUnknown Source
at java.security.AccessController.doPrivilegedNative Method
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilegeUnknown Source
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilegeUnknown Source
at java.awt.EventQueue$4.runUnknown Source
at java.awt.EventQueue$4.runUnknown Source
at java.security.AccessController.doPrivilegedNative Method
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilegeUnknown Source
at java.awt.EventQueue.dispatchEventUnknown Source
at java.awt.EventDispatchThread.pumpOneEventForFiltersUnknown Source
at java.awt.EventDispatchThread.pumpEventsForFilterUnknown Source
at java.awt.EventDispatchThread.pumpEventsForHierarchyUnknown Source
at java.awt.EventDispatchThread.pumpEventsUnknown Source
at java.awt.EventDispatchThread.pumpEventsUnknown Source
at java.awt.EventDispatchThread.runUnknown Source

网上大概搜了一遍,都说在sql语句前加上SET NOCOUNT ON ,我试了一下依然提示啊。

插入操作执行的是excuteUpdate方法...你try语句块那儿写错了...

你执行的是插入操作,执行sql语句意思是插入相应的值,如果需要返回有结果,需要重新执行查询操作!

栏目列表

广告位

澳门博彩导航网址