Disable autocommit in SQL Developer when using MySQL
Asked Answered
T

8

9

I'd like to connect to a MySQL server with Oracle SQL Developer, but with autocommit disabled. By default, all MySQL connections have autocommit enabled, which is rather odd.

The global setting in SQL Developer is unchecked, and

set autocommit=0;

results in the error

set autocommit script command forced off, as connection level autocommit is on.

In the connection's settings are no other options besides hostname, port and a drop down box for database selection.

I'm using SQL Developer 3.2.10 with latest JDBC connector, 5.1.

Tube answered 24/7, 2013 at 6:32 Comment(0)
M
3

You will run into an error if you try and use

start transaction;

-- Your SQL statements

commit;

...out of the box on a MySQL database in SQLDeveloper (as Michael mentioned in a comment to another answer.)

In order to get around this error that Michael referenced in his comment you can use the following hint:

/*sqldev:stmt*/start transaction;

-- Your SQL statements

/*sqldev:stmt*/commit;

Found this information here.

Mlawsky answered 27/11, 2013 at 17:17 Comment(0)
I
13

In Oracle SQL Developer 4 the setting has moved:

Tools > Preferences > Database > Advanced > Autocommit

Default is off.

Alternative:

set autocommit off;
Iselaisenberg answered 26/5, 2016 at 10:35 Comment(1)
This setting is ignored when you're using MySQL database, unfortunately.Splatter
M
3

You will run into an error if you try and use

start transaction;

-- Your SQL statements

commit;

...out of the box on a MySQL database in SQLDeveloper (as Michael mentioned in a comment to another answer.)

In order to get around this error that Michael referenced in his comment you can use the following hint:

/*sqldev:stmt*/start transaction;

-- Your SQL statements

/*sqldev:stmt*/commit;

Found this information here.

Mlawsky answered 27/11, 2013 at 17:17 Comment(0)
C
1

Turn off the auto commit option in SqlDeveloper. Go to Tools -> Preferences -> Database -> ObjectViewer Parameters and uncheck the box Set Auto Commit On.

Capybara answered 19/2, 2014 at 16:8 Comment(1)
Can't call rollback when autocommit=true :-)Tube
A
0

enclose the commands with 'start transaction' and 'commit'. mysql turned off auto-commit on 'start transaction' until 'commit' or 'rollback' is issued

Avestan answered 22/11, 2013 at 17:56 Comment(1)
This will end in an error: Error starting at line 1 in command: START TRANSACTION Error report: Unable to open file: "TRANSACTION.sql"Tube
H
0

Outils-->Preferences-->Fenetre SQL--> Validation automatique de transactions SQL uncheck the check box

Horne answered 10/2, 2014 at 13:53 Comment(1)
Nope, this does not toggle autocommit on MySQL connections.Tube
U
0

You can turn on AutoCommit by clicking on Tools | Preferences Open the Database Tree select Worksheet parameters Check on the Autocommit in SQL Worksheet box

Unipersonal answered 8/1, 2015 at 13:6 Comment(0)
C
0
set autocommit=false;--or true
--comment required/**/
/*sqldev:stmt*/start transaction; 
--your sql
/*sqldev:stmt*/commit;
/*sqldev:stmt*/rollback;
Conscript answered 17/5, 2017 at 1:49 Comment(0)
L
-1

connect sqlplus as sysadmin and type command "SET AUTOCOMMIT OFF" it is off as command. and if u want to check it is off or not the type command "show autocommit" and it show like "autocommit OFF"

Lichi answered 10/11, 2014 at 12:29 Comment(1)
This question relates to Oracle SQL Developer that connects to a MySQL database. No sqlplus involved.Tube

© 2022 - 2024 — McMap. All rights reserved.