[
https://issues.apache.org/jira/browse/EMPIREDB-283?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16740674#comment-16740674
]
Rainer Döbele commented on EMPIREDB-283:
----------------------------------------
Dear Gunnar,
as I only have an SQL Server 2014 available (will have to install 2016 first),
I have not been able to reproduce the behaviour yet.
However a few general things:
The Statement is executed in the function DBDatabaseDriver.executeSQL(String
sqlCmd, Object[] sqlParams, Connection conn, DBSetGenKeys genKeys) as you
probably found out. The call to count = pstmt.executeUpdate(); should never
return below 0 values (except however for DLL-Statements).
For normal (DML) statements, it should always return 0 or greater values or
throw an SQLException.
Can you please check the following:
* What JDBC driver are you using? I am currently on sqljdbc4-4.0.jar. Might be
worth updating!
* Can you please try to reproduce this with the basic example that we ship
with our distribution? In order to run with SQL-Server please add a dependency
to the pom.xml (put your SQL Driver in the local repository) and afterwards
edit the config.xml file. Change the property <databaseProvider> from "hsqldb"
to "sqlserver" and then to the section <properties-sqlserver>. Change the
jdbcURL, jdbcUser und jdbcPwd to you SQL Server instance. The user should be
able to create databases. Then goto SampleApp.java, add
db.setPreparedStatementsEnabled(true) in the main method and run the class.
What is the first statement that fails?
* Have you tried to ignore the exception and commit the changes? If so, have
the statements worked and has the data been changed?
Hopefully this should give us an idea what the problem is.
Regards,
Rainer
> PreparedStatements not working with MS SQL-Server > 2012
> --------------------------------------------------------
>
> Key: EMPIREDB-283
> URL: https://issues.apache.org/jira/browse/EMPIREDB-283
> Project: Empire-DB
> Issue Type: Bug
> Components: Core
> Affects Versions: empire-db-2.4.4, empire-db-2.4.6, empire-db-2.4.7
> Environment: JAVA 8, WIN2K12R2, MS-SQL-SRV > 2012, JDBC-Driver 4.2,
> 6.0, 7.0
> Reporter: Gunnar Kappei
> Priority: Major
>
> Since the company I'm working at upgraded their database-servers from MS-SQL
> 2012 to 2016, there seems to be an issue when using PreparedsStatements
> together with Empire-DB.
> When enabling PreparedStatements via
> DBDatabase#setPreparedStatementsEnabled(true), it's not possible to perfom
> SQL-UPDATEs.
> Debugging the sources I found out, that the problem is located nside the
> executeSql-method of the DBDatabase / DBDatabaseDriverMSSQL classes. The
> number of affected records is < 0. Therefore an exception is thrown. There is
> no issue with INSERT statements.
> When disabling PreparedStatements, the code is working fine again since it
> did for years now. Tried Empire-DB 2.4.4, 2.4.6, 2.4.7 and several versions
> of the official JDBC driver from MS. On several database-servers. Getting the
> same result every time.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)