Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to connect tContextLoad to tMysqlConnection

Hi all,
I am trying to establish connection from tContextLoad to tMysqlConnection. Before to accomplish the process I have prepared an excel file that contain context variable for the database connection (e.g : host, port, username, database, table, password).
These context will be loaded from tFileInputExcel using tContextLoad. As the context successfully loaded, I try to connect tContextLoad to tMysqlConnection. This is to ensure that I can retrive the data based on the context variable that are stated in excel file without inserting any variables in the tMysqlConnection components. How do I get an automatic default database connection from the context I've loaded without putting anything in tMysqlInput component settings back?
Is this possible? Is there any alternative way to accomplish above processes?
Your help is very much appreciated. Thank you.
Labels (2)
20 Replies
Anonymous
Not applicable
Author

Hi
The job design is not wrong, it should be:
tContextLoad
|
onsubjobok
|
tMysqlConnection
|
onsubjobok
|
tMysqlInput--main--tLogRow
|
onsubjobok
|
tMysqlCommit
tMysqlConnection: use context variable to set the db setting, create a db connection.
tMysqlInput: check the option 'use an existing connection', it will use the db connection created by tMysqlConnection.\
tMysqlCommit: commit the change and close the db connection.
Have a look at the user component manual and learn tContextLoad component, there is an example about this component .
Anonymous
Not applicable
Author

thank you so much shong..thank you for replying my questions..
Anonymous
Not applicable
Author

Dear Shong.
I am a little bit confuse on how to use the context variable to set the db setting in order to create a db connection. Can you show me the processes..
Thank you..
Anonymous
Not applicable
Author

hi
Define a context variable called host in this job. In the Host field of db component, set the field with context variable like:
context.host
Anonymous
Not applicable
Author

Dear Shong.
Thank you for replying my question. Is it possible that I set the context variable in the excel file as the picture above instead of I set the context variable in the field of db components?. If yes can you show me the steps that should be taken?
Thank You Shong.
Anonymous
Not applicable
Author

Hi
No, the db fieldds must be filled in static value or context variable. The value of context variable can be stored in excel file. Set the db fields with context variables, as my job showed, use tContextLoad to load dynamically the value from excel file at runtime.
Anonymous
Not applicable
Author

Hi Shong,
Do you know what is the meaning for these statement :
Exception in component tMysqlInput_1
java.sql.SQLException: Cannot convert value '1' from column 1 to TIMESTAMP.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:1339)
at com.mysql.jdbc.ByteArrayRow.getTimestampFast(ByteArrayRow.java:129)
at com.mysql.jdbc.ResultSetImpl.getTimestampInternal(ResultSetImpl.java:6754)
at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:6073)
at talend.tcontextload_0_1.tContextLoad.tMysqlInput_1Process(tContextLoad.java:1523)
at talend.tcontextload_0_1.tContextLoad.tMysqlConnection_1Process(tContextLoad.java:1170)
at talend.tcontextload_0_1.tContextLoad.tFileInputExcel_1Process(tContextLoad.java:1037)
at talend.tcontextload_0_1.tContextLoad.runJobInTOS(tContextLoad.java:1998)
at talend.tcontextload_0_1.tContextLoad.main(tContextLoad.java:1837)
disconnected
Caused by: java.sql.SQLException: Bad format for Timestamp '1' in column 1.
at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:1313)
Thank You..
Anonymous
Not applicable
Author

Hi
As the error showed, bad format for timestamp "1". You define the data type of column1 as Date, but the value of this column is 1, so please check you really need Date type for this column or Integer/int type?
Anonymous
Not applicable
Author

thank you so much shong..