Multiple parameters in Coldfusion MYSQL Connection String Not Being Recognised - mysql

I am trying to add the following two parameters to a Coldfusion MySQL DSN connection string:
allowMultiQueries=TRUE
autocommit=FALSE
When I add either one parameter to the connection string as a single parameter connection string, the setting is picked up fine in Coldfusion.
For example allowMultiQueries=TRUE works and allows multiple queries to be processed. Alternatively autocommit=FALSE disables autocommits as expected.
However, combining both parameters in the connection string saves without error in the CF Admin when updating the DSN, but ignores the last parameter when my code is run.
Example of that connection string: allowMultiQueries=TRUE&autocommit=FALSE
So in this example, the autocommit parameter is ignored and I get a CF error:
An exception occurred when committing the transaction.
The root cause of this exception was: java.sql.SQLException: Can't call commit when autocommit=true.
Why is Coldfusion not recognising the second parameter? I tried delimiting the variables with a ; instead of an & but that threw an error when trying to save the datasource and wouldn't allow it.
This is for Coldfusion 2021.0.03.329779 and MYSQL 8.0.23 using the mysql-connector-java-8.0.22.jar file (recommended as later version had other known bugs with datetime types)
Any insight would be appreciated.

Related

Hibernate/mysql - Batch update returned unexpected row count and ascii characters

I was facing a problem deleting entity read by hibernate. A simple call like load entity from database and immediately delete the entity without any change was failing with the exception
org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
I finally traced the error to an errant string which had following ascii characters - 239 (0xef), 191 (0xbf) and 189 (0xbd). After removing these characters, everything works properly. Since hibernate delete call matches all the fields in the where clause while deleting, call was failing when these characters are present in the string.
It seems like there is issue with character encoding in our setup somewhere as entities/columns returned by hibernate can not be used as part of where clause in criteria - or something is getting lost in translation.
What should I do - mysql setup or hibernate setup so that these issues can be avoided in future
I remember I used to call SET CHARACTER SET 'utf-8'` at the beginning of each mysql session. That was in PHP. Now Hibernate / JDBC should handle that, but still you need to set it on both server and client.
See the server config and the JDBC config.
You need to have the database, the connection, and the client encoding all aligned.
Edit: Also note that the tables and columns may have their own encoding, so check that in the INFORMATION_SCHEMA.
Also, I'd suggest also to watch the MySQL server logs which I belive would tell you they failed performing the query, or perhaps warn on the invalid value.

SSIS: The connection string format is not valid. It must consist of one or more components of the form X=Y, separated by semicolons

I have a variable in my SSIS package set to the following:
"Provider=Microsoft.ACE.OleDb.12.0;Data Source=C:\Users\CurrentUser\Dropbox\Eval\SynchDB.accdb;Persist Security Info=False;"
Then I have an OLE DB Connection in my connection manager and I set the Connection string property of that connection to my variable.
I also created a data flow task with an OLE DB Source that is set to that connection, then I selected the table I needed, from the dropdown. But when I click on "Columns", I get an error:
"The connection string format is not valid. It must consist of one or more components of the form X=Y, separated by semicolons. This error occurs when a connection string with zero components is set on database connection manager"
Which does not make sense since my connection string is valid. Can anyone help me understand what is going on here?

SSIS Package Based on a avariable

Hi I've an SSIS Package which Does tasks like a)Truncate Last 7 days data from a table if any and then re-load it and all theses are placed in a sequence container and it run's fine.Now I'm planning to remove the hard coded value of 7 and introduce a variable NoOfDays which I can provide at run time.Can this be achieved?
I added a variable and tried to map it to the parameter of the ExecuteSQL Task...It gave the following error:
I even want the value to be available to the next step Data Flow Task
[Execute SQL Task] Error: Executing the query "delete from USER_CONTENT where CONVERT..." failed with the following error: "The variable name '#NoOfDays' has already been declared. Variable names must be unique within a query batch or stored procedure.
Statement(s) could not be prepared.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
The query I'm using is
delete from USER_CONTENT
where CONVERT(date,ISSUE_DATE)>=CONVERT(DATE,GETDATE()-7)
and it is against an OLE-DB connection.
I do not have enough points to post a comment so I will have to ask you this way: are you using query parameters with a "?", if not, then in order to use a package variable with a stored procedure, you will need to write your statement to use them, also, don't name your parameters, use the default 0,1,2 etc.. that the package assigns.

Programmatically setting a connection string for sql 2012 ssis packages

I am having an issue programmatically setting connection strings.
Here is an overview of my project. I am using 2012 SSIS and have two connections in my connection managers (Source and Destination and both are OLE DB connections). I have multiple packages I want to run. Each of these packages only contain Execute SQL tasks. Each task I have the SQL Statement connection type set to OLE DB, the connection is Destination, the SQL Source Type is a File Connection, and the File Connection is a file located on my C drive that is a script file that I generate in my program.
I have these packages deployed on my server which is a 2012 instance. The source and destination connections are also on my server but on a 2008 R2 instance.
I loop through N number of databases. In each loop I can set the Connection String and IntialCatalog properties by executing a SQL statement:
DECLARE #var sql_variant = N'Data Source=MyServerName\SQL2008R2;Initial Catalog=DatabaseName1;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;'
EXEC [SSISDB].[catalog].[set_object_parameter_value] #object_type=20, #parameter_name=N'CM.Destination.ConnectionString', #object_name=N'MAC', #folder_name=N'MAC', #project_name=N'MAC', #value_type=V, #parameter_value=#var
This does work since I can open up the configure option on my project and see that the connection string and initial catalog values change while I am stepping through the program. (I didn't include the SQL for the initial catalog but it is similar to the connection string)
Now when I execute this through my program, I the following errors:
The connection "{9C2C8088-CE67-4D93-81B8-EC364D6E78D1}" is not found. This error is thrown by Connections collection when the specified connection element is not found.
Is there a way to update the package so the Execute SQL Tasks have an updated connection?
As a side note, if I open the packages in Visual Studio and modify the connections, the packages execute. It is when I try to programmatically change the connections and execute or if I try to execute the packages that are deployed on the server when it errors.
I did see this question and although it is similar, I think it varies enough to have a separate question.
SSIS Connection not found in package. I have found a lot of great info here, just not what I am looking for yet.
Any help/advice is greatly appreciated!
Thanks
Mark
My suggestion would be to move your database looping and connection string setting inside your packages by taking advantage of SSIS's Foreach Loop container.
Create a new string variable in your package. Call it "User::DestinationConnectionString".
Right-click on your Destination connection and choose Properties.
Create an Expression for your connection's ConnectionString property and set to your User:DestinationConnectionString variable.
Put all of your connection strings in a table. Let's call it ConnectionStrings.
Create an Execute SQL task at the beginning of your package. Let's call it "Get Connection Strings."
Set the connection to where your ConnectionStrings table is.
Write a query to retrieve the connection strings.
Set the ResultSet to Full Result Set.
Set your Result Set to a variable of type Object. Let's call it User::ConnectionStrings. (The Result Name should be 0.)
Create a ForEach Loop Container. Name it "For Each Connection String."
Set the Collection Enumerator to Foreach ADO ENumerator.
Set the ADO Object Source variable to User::ConnectionStrings.
In the Variable Mappings tab, map Index 0 to your User::DestinationConnectionString variable.
Place your Execute SQL tasks inside your foreach loop.
Now when the package runs, it will loop through each connection string, assign it to the variable, which the connection uses to get its connection, which the SQL task then runs against.
If you don't know your database connection strings until runtime, you can just write them into the table then and then kick off your package.

SSIS 2008 Execute SQL output parameter mapping datetime2 problem

I'm trying to use an Execute SQL Task in SSIS 2008 to map a store procedure output parameter to a package variable.
The package variable is SSIS type DateTime and the store procedure parameter is SQL type DATETIME.
The SQL Statement is EXEC GetCurrentDate #CurrentDate=? and in the parameter mapping screen, the parameter is mapped to the package variable with direction Output and Data Type DBTIMESTAMP specified.
When I run the package I get the following error:
[Execute SQL Task] Error: Executing
the query "EXEC GetCurrentDate
#CurrentDate=? " failed with the
following error: "The type of the
value being assigned to variable
"User::CurrentDate" differs from the
current variable type. Variables may
not change type during execution.
Variable types are strict, except for
variables of type Object. ". Possible
failure reasons: Problems with the
query, "ResultSet" property not set
correctly, parameters not set
correctly, or connection not
established correctly.
If I run a trace on the query being run I see the type is being assumed as datetime2:
declare #p3 datetime2(7)
set #p3=NULL
exec sp_executesql N'EXEC GetCurrentDate #CurrentDate=#P1 ',N'#P1 datetime2(7) OUTPUT',#p3 output
select #p3
Does anyone know why it is assuming the type is datetime2?
Thanks
Found the answer on a Micorsoft Connect bug report:
We are closing this case as this is expected behaviour and is a result of the new sql datetime type change. You are using a native oledb connection manager for sql task, in the process of COM interop, we use VARIANT to hold the value and the only way to prevent data loss is to store the value as BSTR variant. If you change User::dateParam to String type it will work, or you can switch to use managed connection manager to bypass the COM interop.
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=307835
Try specifying the inout/output parameters as DATE rather than DBTIMESTAMP in the SSIS task.
This certainly works in SSIS 2005 packages I've worked on.
It's also worth taking a look at this link, which covers this as well as a couple of other issues with SSIS and dates.