Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360509 - Java runtime throws SQL exception when fetching rows of data from MySQL
Summary: Java runtime throws SQL exception when fetching rows of data from MySQL
Status: CLOSED WONTFIX
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-11 04:12 EDT by fahua jin CLA
Modified: 2017-02-23 14:17 EST (History)
2 users (show)

See Also:


Attachments
table schema (236 bytes, text/plain)
2011-10-11 04:13 EDT, fahua jin CLA
no flags Details
SQL data (2.86 KB, text/plain)
2011-10-11 04:14 EDT, fahua jin CLA
no flags Details
The sample project. (48.86 KB, multipart/x-zip)
2011-10-11 04:14 EDT, fahua jin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description fahua jin CLA 2011-10-11 04:12:26 EDT
Build Identifier: 0.7.0.v201110100901

It will take some time to reproduce the problem, you'll have to set up the MySQL environment before starting to reproduce it.

Prepare the database environment:
1) Setup the MySQL 5.5
2) Create schema named eglsample. You can use the MySQL workbench to visually create the schema & table.
3) Refer to the attached schema.txt to created a table named employee in eglsample schema.
4) Insert the data to the employee table. Please refer to the attached employee_data.txt for SQL statements to insert the data.

Setup the workspace,
1) Create a new workspace, and add a MySQL SQL resource binding - you can refer to the DD file in the attached project.
2) Right click the Prg1.egl in the server package > Run As > EGL Java Main application.
3) You can find that the first name column in the table will be print, but it throws a SQL exception when finishing execution. Refer to below for the Java exception stack trace.

-------------------------
Can't call commit when autocommit=true: [sqlstate:null][sqlcode:0]
eglx.persistence.sql.SQLException Can't call commit when autocommit=true: [sqlstate:null][sqlcode:0]
	at eglx.lang.AnyException.fillInStackTrace(AnyException.java:187)
	at java.lang.Throwable.<init>(Throwable.java:181)
	at java.lang.Exception.<init>(Exception.java:29)
	at java.lang.RuntimeException.<init>(RuntimeException.java:32)
	at eglx.lang.AnyException.<init>(AnyException.java:32)
	at eglx.persistence.sql.SQLException.<init>(SQLException.java:25)
	at org.eclipse.edt.javart.util.JavartUtil.makeEglException(JavartUtil.java:281)
	at eglx.persistence.sql.SQLDataSource.commit(SQLDataSource.java:83)
	at org.eclipse.edt.javart.resources.ResourceManager.commit(ResourceManager.java:63)
	at org.eclipse.edt.javart.resources.RunUnitBase.commit(RunUnitBase.java:218)
	at org.eclipse.edt.javart.resources.RunUnitBase.endRunUnit(RunUnitBase.java:282)
	at org.eclipse.edt.javart.resources.RunUnitBase.start(RunUnitBase.java:245)
	at server.Prg1.main(Prg1.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.edt.javart.ide.MainProgramLauncher.main(MainProgramLauncher.java:68)
Caused by: java.sql.SQLException: Can't call commit when autocommit=true
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:934)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931)
	at com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.java:1655)
	at eglx.persistence.sql.SQLDataSource.commit(SQLDataSource.java:80)
	... 10 more


Reproducible: Always
Comment 1 fahua jin CLA 2011-10-11 04:13:18 EDT
Created attachment 204925 [details]
table schema
Comment 2 fahua jin CLA 2011-10-11 04:14:00 EDT
Created attachment 204926 [details]
SQL data
Comment 3 fahua jin CLA 2011-10-11 04:14:50 EDT
Created attachment 204927 [details]
The sample project.
Comment 4 Joseph Vincens CLA 2011-10-14 16:21:16 EDT
According to the documentation add relaxAutoCommit=true to the end of your JDBC url.
The & is used to concat multiple properties. Since you are already suppling a user and password on the URL you would add  &relaxAutoCommit=true.

Also note you can put the user and password in a dictionary and pass the dictionary to the SQLDataSource constructor. The constructor converts the dictionary to properties and passes it to the DriverManager when we get the connection. You may also be able to pass the relaxAutoCommit property in using the dictionary.
Comment 5 fahua jin CLA 2011-10-19 21:19:51 EDT
(In reply to comment #4)
> According to the documentation add relaxAutoCommit=true to the end of your JDBC
> url.
> The & is used to concat multiple properties. Since you are already suppling a
> user and password on the URL you would add  &relaxAutoCommit=true.
> 
> Also note you can put the user and password in a dictionary and pass the
> dictionary to the SQLDataSource constructor. The constructor converts the
> dictionary to properties and passes it to the DriverManager when we get the
> connection. You may also be able to pass the relaxAutoCommit property in using
> the dictionary.

Thanks Joe.