CF10 , MYSQL SQL_SELECT_LIMIT=DEFAULT - mysql

I just set up CF10, win2008, IIS 7.5 with mysql 5.6. But we are getting this error:
Error Executing Database Query.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=DEFAULT
This error is removed when I explicitly set "LIMIT" to the queries.
(Update from comments)
Here is an example:
<cfquery name="dds" datasource ="#Request.Datasource#">
SELECT *
FROM tblaccounts
LIMIT 100
</cfquery>
As far as my research shows, it's an incompatibility with the new version of mysql 5.6.

Borrowing some from the answers above with more detail:
We were having the same problem and it was fixed by updating the JDBC file. Since ColdFusion 10 only supports MySQL 5.0 and 5.1, you need to update the Connector as mentioned above.
To update the JDBC Connector on your Windows machine,
Obtain the .zip connector from the link provided above
Open the zip archive and locate the mysql-connector-java-5.1.23-bin.jar
Copy this .jar file to C:\ColdFusion10\cfusion\lib\
Open Services (Start > Control Panel [Optional] > Administrative Tools > Services)
Stop/Start the "ColdFusion 10 Application Server" service
To verify the new .jar is has been recognized by ColdFusion, login to your ColdFusion Administrator, click on "Settings Summary" under "Server Settings". Search for "mysql". You should see the .jar file listed under the "CF Server Java Class Path" section. There is no need to re-setup datasources. These changes should automatically apply.

From what I understand another option should be to update the JDBC driver to the latest MySQL JDBC Driver. You can find instructions on using the latest JDBC driver here: (though the instructions may be a bit old, it should still work pretty much the same way).
FYI ColdFusion 10 only supports MySQL 5.0 and 5.1.

Thanks much Clark - we just had the same issue with CF9
This actually applies to CF9 as well.
Step 3 is then: Copy this .jar file to C:\ColdFusion9\lib\
Step3a Rename the old driver mysql-connector-java-commercial-5.1.11-bin.jar.old
Otherwise drivers may conflict. (happened before)
After the update the bug seemed to be gone. :)

MySQL 5.6 is now supported in ColdFusion 10 update 11, details here: http://helpx.adobe.com/coldfusion/kb/coldfusion-10-update-11.html

MySQL deprecated SET OPTION a long time ago, see the docs, and it was removed in 5.6
You need to use SET without the OPTION statement,
SET SQL_SELECT_LIMIT = 100;
Will do what you want.
Be aware that this sets the default for a single connection. To ensure that your subsequent query uses the same connection wrap them in a <cftransaction>
<cftransaction>
<cfquery name="tmp" datasource ="#Request.Datasource#">
SET SQL_SELECT_LIMIT = 100;
</cfquery>
<cfquery name="dds" datasource ="#Request.Datasource#">
SELECT *
FROM tblaccounts;
</cfquery>
</cftransaction>
An alternative is to enable multiple queries for the datasource, but this is not recommended for security reasons.

Related

How to fix ODBC Driver 8.0 SQL syntax error in SSIS?

I have a SSIS package which is used to export data from a MySQL database to a SQL database.
For some reason, I can only read data using the ODBC Source item but I cannot preview the table, also, while doing some other tests I found out I can't insert data with the ODBC Destination item either.
Whenever I try I get this error:
ERROR [42000] [MySQL][ODBC 8.0(w) Driver][mysqld-5.7.23]You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near "TABLENAME"
at line 1 (myodbc8w.dll).
I'm using MySQL 5.7.23 and MySQL Connector/ODBC 8.0. I have tried switching between ANSI and Unicode connectors; downgrading the connectors version (tried it with 5.3, 5.2 and 5.1); changing database, table and column codification; changing the data access mode in the ODBC Source item (was using "Table Name" by default); remaking the task. Everything results in the same error, even on different computers and databases.
EDIT:
Using #Hadi second workaround lead to some interesting results (the first one didn't work for me).
Using either the ADO.NET or ODBC connector, the provided query resulted in an error.
Error Code: 1231. Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'
After modifying the query to
set sql_mode = 'STRICT_TRANS_TABLES, NO_ENGINE_SUBSTITUTION, ANSI_QUOTES'
the error changed to a warning.
set sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES' 0 row(s) affected, 1 warning(s): 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
Still, it worked partially. Any quotations, accents, or any other symbol surrounding any selected table name had to be removed. That made it work fine when inserting data, but when retrieving data it had to be done either from a SQL command or by creating 2 different connections.
While searching for the issue i found some helpful links that mentioned some workaround:
(1) Connecting to MySQL issue
Connecting to MySQL from SSIS
In this link the author mentioned 2 methods to connect to MySQL (using ODBC and ADO.net). He mentioned that while trying to retrieve tables using ODBC he received the same error that you have listed in the question, and he mentioned the solution as below:
Switching to use a SQL query instead, and that worked just fine. I was able to pull back both the correct metadata, with one small problem - the varchar(50) columns came back with a length of 51. This resulted in some warnings, but the package ran correctly.
(2) Writing to MySQL issue
Writing to a MySQL database from SSIS
In this article the author mentioned how to write to a MySQL destination using ADO.Net destination, he mentioned the solution below:
For the ADO.NET Destination to work properly, the MySQL database needs to have the ANSI_QUOTES SQL_MODE option enabled. This option can be enabled globally, or for a particular session. To enable it for a single session:
Create an ADO.NET Connection Manager which uses the ODBC driver
Set the connection manager’s RetainSameConnection property to True
Add an Execute SQL Task before your data flow to set the SQL_MODE – Ex. set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES'
Make sure that your Execute SQL Task and your ADO.NET Destination are using the same connection manager.
Other similar links
SSIS problems with MySQL Connector/ODBC 5.3.8
SSIS and MySQL - Table Name Delimiter Issue

Error with the version of the database in liferay 7

I work with Eclipse and I want to use the version 7 of Liferay but when I run my Tomcat server I have an error with MySQL.
Please upgrade to at least MySQL 5.6.4. The portal no longer supports older versions of MySQL
Like this the problem is pretty obvious but my SQL version is already 5.7.19
I have check my driver of MySQL in preference->data management->connectivity->driver definition and my MySQL JDBC Driver is 5.1
I want to know if someone already had this issue and know how to fix it
This is how the version gets validated, and this is how the version string gets constructed. I'd say: Please make extra extra extra sure that you are addressing the mysql server that you intend to address:
You can check your mysql version from the mysql command line client by executing select version();. Get your credentials and database URL from Liferay's portal-ext.properties or your appserver's connection pool configuration, depending on where you configured it.

Error code 1064, SQL state 42000: You have an error in your SQL syntax;

I'm using latest version of MySQL ==> mysql-5.6.10-winx64.zip
Created the database and every thing is ok 'I think'
when I try to execute this simple command;
"select * from family"
I got this error :
Error code 1064, SQL state 42000: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=DEFAULT' at
line 1
I've spent much time searching for a solution but no solution was found :(
That looks like an error coming from a JDBC driver. When the JDBC driver initializes the connection, it sends several commands to the MySQL server, one of which is:
SET OPTION SQL_SELECT_LIMIT=DEFAULT
The problem is that the SET OPTION syntax has been deprecated for some time and is now no longer valid in MySQL 5.6. Here's a relevant bug conversation from MySQL's bug database:
Bug #66659: mysql 5.6.6m9 fails on OPTION SQL_SELECT_LIMIT=DEFAULT
Try upgrading your JDBC MySQL driver. The bug conversation lists some other options in case upgrading the driver is not an option.
I followed the instructions above and this worked for me!
Download latest jar file from here:
http://dev.mysql.com/downloads/mirror.php?id=412737
Unzip it
Copy jar file "mysql-connector-java-5.1.25-bin.jar"
to this folder: C:\Program Files\NetBeans 7.3\ide\modules\ext
In Netbeans IDE: Disconnect from database.
Click Services. Expand Drivers. Right-click on MySQL and press Customize.
Add latest driver
Remove previous driver.
Re-connect to dabatase within IDE.
I had the same problem few weeks back. Followed the following steps and it very much resolved the issue.
Copied the latest version (mysql-connector-java-5.1.23-bin) of the jar file to ..\NetBeans 7.3\ide\modules\ext. My earlier version of the driver was mysql-connector-java-5.1.18-bin.
Change the driver version within NetBeans IDE. In the IDE's Services window, expand Drivers -> right-click on MySQL (Connector/J driver) and select Customize. Remove the earlier driver and point it to the latest one (C:\Program Files (x86)\NetBeans 7.3\ide\modules\ext\mysql-connector-java-5.1.23-bin.jar). Click ok and restart IDE.
This should resolve the problem.
If the driver suggestion does not work, check your sql for unprintable characters. I just spent an hour troubleshooting this issue only to discover a hidden u+200b character at the end of my sql statement.
I got the same Error when i was dumping mysql table structure file in to DB. Mistake was putting the Syntax for dropping all table before but not checking their existence in the Database.
Issue was at " DROP TABLE usermgmt".
I removed that code of lines of dropping tables and it proceeded with out any error this time.
I prefixed the name of the table with the database name such as
select * from database_name.table_name;
and it worked perfectly, so most likely there's a name conflict.

Insert error using Linked Server MySQL

I have created a linked server using ODBC driver with following provider string
DRIVER={MySQL ODBC 5.1 Driver};SERVER=HOST;USER=uid;PASSWORD=pw;OPTION=3
My linked server is named MYSQL. If i do Select and UPDATE in that way it works right
SELECT * FROM OPENQUERY(MYSQL,'SELECT * FROM DatabaseName.Table')
UPDATE OPENQUERY(MYSQL, 'SELECT * FROM DatabaseName.Table where test=0') SET test=1
when i try to perform an insert with following syntax
INSERT OPENQUERY(MYSQL,'SELECT Column1, Column2, Column3 from DatabaseName.Table WHERE 1=0') VALUES (10,20,30)
i have this following error
The OLE DB provider "MSDASQL" for linked server "MYSQL" could not INSERT INTO table "[MSDASQL]". Commands out of sync; you can't run this command now.
I think you've got the same problem as this thread on another forum. From the answer that seems to have solved the problem for people there, it looks like your missing the database name from your provider string. Try adding DATABASE=mydb; to your provider string.
Here is the original answer:
Apparently if you try to create the linked server using studio and the
various menus, a small detail is not saved in the connection string,
which is the database!
EXEC master.dbo.sp_addlinkedserver #server='MYSQL', #srvproduct='MySQL',
#provider='MSDASQL', #provstr='DRIVER={MySQL ODBC 5.1
Driver};SERVER=HOST;Port=3306;USER=uid;PASSWORD=pw;OPTION=3;DATABASE=mydb;
the bug in the odbc driver seems to affect only the insert statement
and has been around since 2008... i would have hoped that mysql fixed
it by now...
after you create the linked server using the procedure as above, the
insert works as well as all the rest!
I just experienced the same problem and managed to solve it by deactivating Force use of forward-only cursor and Don't cache results for forward-only cursor for my ODBC connection.
I don't know for sure if both options need to be disabled. I got the hint from here
I linked SQL Server 2012 to MySQL v5.1 via MySQL ODBC/Connector v5.1.11, 64-bit. My link data source is configured to use a system ODBC DSN which already had the MySQL database specified (this is in relation to the previous answers) and yet I still got the error before deactivating those cursors options (by default they are not enabled for new data sources, I was the one who enabled them at some point).

Oracle SQL Developer Error: vendor code 1317

I am using Oracle SQL Developer to browse a MySQL database. When I browse table with Columns tab (shows table definitions), some of tables will display an Error Encountered dialog that says:
Vendor code 1317
Are you using the latest version of SQL Developer?
Might be worth asking this question on the SQL Developer Forum on OTN as it is well supported by the Oracle SQL Developer team.
I had a quick search and the only thread I could find was this one in which one of the responses reports the same problem as you but unfortunately there is not a direct response to it.
SQL Developer doesn't support 5.1.x series of jdbc mysql connector... you need to set up sql developer to use mysql-connector-java-5.0.4 in driver settings. You better use this one, because I was having the issue even with mysql-connector-java-5.0.8
To browse MYSQL DB with version Oracle SQL Developer (version 2.1.2.64) and avoid the above problem, you must use mysql/J connector: mysql-connector-java-5.0.4.
mysql-connector-java-5.0.8 or mysql-connector-java-5.1.* WILL NOT work.
1317 seems to be the mySQL code for ER_QUERY_INTERRUPTED.
Maybe some sort of timeout ?
Please check the following link for the answer
http://download.oracle.com/docs/cd/E15846_01/doc.21/e15222/intro.htm#CHDIEGDD
This is an excerpt from the above link:
Database: Third Party JDBC Drivers
The Third Party JDBC Drivers pane
specifies drivers to be used for
connections to third-party
(non-Oracle) databases, such as IBM
DB2, MySQL, Microsoft SQL Server, or
Sybase Adaptive Server. (You do not
need to add a driver for connections
to Microsoft Access databases.) To add
a driver, click Add Entry and select
the path for the driver:
For IBM DB2: the db2jcc.jar and
db2jcc_license_cu.jar files, which are
available from IBM
For MySQL: a file with a name similar
to mysql-connector-java-5.0.4-bin.jar,
in a directory under the one into
which you unzipped the download for
the MySQL driver
For Microsoft SQL Server or Sybase
Adaptive Server: jtds-1.2.jar, which
is included in the jtds-1.2-dist.zip
download
For Teradata: tdgssconfig.jar and
terajdbc4.jar, which are included
(along with a readme.txt file) in the
TeraJDBC__indep_indep.12.00.00.110.zip
or
TeraJDBC__indep_indep.12.00.00.110.tar
download
Alternative: As an alternative to
using this preference, you can click
Help, then Check for Updates to
install the JTDS JDBC Driver for
Microsoft SQL Server and the MySQL
JDBE Driver as extensions.
To find a specific third-party JDBC
driver, see the appropriate Web site.
For MySQL, use the MySQL 5.0 driver, not
5.1 or later, with SQL Developer release 1.5.
You must specify a third-party JDBC
driver or install a driver using the
Check for Updates feature before you
can create a database connection to a
third-party database of that
associated type. (See the tabs for
creating connections to third-party
databases in the Create/Edit/Select
Database Connection dialog box.)