多个sql命令

时间:2016-04-29 16:18:30

标签: java sql jdbc

我尝试执行多个sql命令,但它在SQL语法中出现了错误;"

import gi
gi.require_version('Gtk', '3.0')

from gi.repository import Gio
from gi.repository import Gtk

class AppWindow (Gtk.ApplicationWindow):
    def __init__(self):
        Gtk.ApplicationWindow.__init__(self)
        self.set_default_size(200, 200)

    # Override the default handler for the delete-event signal
    def do_delete_event(self, event):
        # Show our message dialog
        d = Gtk.MessageDialog(transient_for=self,
                              modal=True,
                              buttons=Gtk.ButtonsType.OK_CANCEL)
        d.props.text = 'Are you sure you want to quit?'
        response = d.run()
        d.destroy()

        # We only terminate when the user presses the OK button
        if response == Gtk.ResponseType.OK:
            print('Terminating...')
            return False

        # Otherwise we keep the application open
        return True

def on_activate(app):
    # Show the application window
    win = AppWindow()
    win.props.application = app
    win.show()

if __name__ == '__main__':
    # Create an application instance
    app = Gtk.Application(application_id='com.example.ExampleApp', flags=0)

    # Use ::activate to show our application window
    app.connect('activate', on_activate)
    app.run()

2 个答案:

答案 0 :(得分:3)

我用三个JDBC驱动程序做了一个小测试:

  • MS SQL:有效,返回两个结果集
  • MySQL:语法错误失败 - 这就是你所看到的
  • HSQLDB:运行,但只返回一个结果集。

所以我想如果这种技术有效,它只取决于JDBC驱动程序。也许它仅适用于MS SQL JDBC。

更新:

它也适用于Postgres。

答案 1 :(得分:1)

请 1.字符串dbUrl =“jdbc:mysql:// yourDatabase?allowMultiQueries = true”; 这应该是你的jdbc连接url