Jemeter test JDBC param - jdbc

This is ThreadGroup:
This is JDBC Connection Config:
![this is JDBC CONNECTIIN CONFIG][2]
The SQL:
SELECT siteid FROM tky_tab_bbsdata WHERE name = ?
And then it throws exception:
java.sql.SQLException: ORA-01008: 并非所有变量都已绑定
the request is :SELECT siteid FROM tky_tab_bbsdata where name = ?
梁段
VARCHAR
I don't know how to solve this problem, the SQL may be right!

You don't need to use parameter outside SQL statement:
Remove values from: parameter values and parameter type
In SQL statement replace your = ? with a real value, use = '[value]'

Related

SQLSyntaxErrorException for executing native SQL IN clause query in Spring boot JPA

I am using MySql Database. I like to write a native query on 'tbl_users'. I wrote the query like below:
#Query(nativeQuery = true, value = "SELECT * FROM tbl_users AS u WHERE u.id IN (:ids)")
List<User> findByUserIdIn(#Param("ids") Set<Long> ids);
But my spring application thrown an exception like
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')'
What will be the right query or how can I overcome this problem. Pls help.

Optional parameter in query does not work for db2 but works in oracle

Below query works fine for Oracle database, but for Db2 it throws error sqlcode -417.
I have looked up similar problems but did not get any definitive answer:
#Query(value = "select * from tableName f where (aC is null or f.a_c = aC)", nativeQuery = true)
Page<tablename> findByFilters(String aC, Pageable pageable);
On execution the error code is -417
One way to solve this problem would be to rewrite the query as the following:
select * from tableName f where f.a_c = coalesce(aC, f.a_c)
The form of query above is likely to be accepted. In order to find out the exact reason of the error you get, it is necessary to trace the actual SQL statement passed to Db2.
Another option of solving the problem may be to add the CAST operator, which would define the data type of your parameter:
select * from tableName f where (cast(aC as integer) is null or f.a_c = aC)
This is suggested in the description of the error you get

ORA-01461: can bind a LONG value only for insert into a LONG column via Access

I am trying to run the below query in Access on a Oracle database :-
UPDATE tblQuotesNew SET tblQuotesNew.Quote_Status = 'Expired'
WHERE tblQuotesNew.Quote_Status='In Progress' AND tblQuotesNew.Date_Quote_Sent<DateAdd('m',-1,Date())
The data type of Quote_Status is VARCHAR2 size 255. The data type of Date_Quote_Sent is Date.
I am connecting to the Oracle database using the code below :-
Dim mydb As DAO.Database
Dim myq As DAO.QueryDef
connectstring = "ODBC;DSN=Comsales;UID=Comsales;PWD=******;SERVER=PDBREPT"
sqltext = "UPDATE tblQuotesNew SET tblQuotesNew.Quote_Status = 'Expired' WHERE tblQuotesNew.Quote_Status='In Progress' AND tblQuotesNew.Date_Quote_Sent<DateAdd('m',-1,Date());"
myq.ReturnsRecords = False
myq.Connect = connectstring
myq.SQL = sqltext
myq.Execute
myq.Close
When I run this query I get a ORA-01461: can bind a LONG value only for insert into a LONG column error.
You're running an Access query (using Access SQL functions) as a Pass-Through query (by setting connectstring = "ODBC;...).
This won't work. Either use Oracle syntax in a Pass-Through query, or Access syntax in a "regular" Access query.
For the latter, tblQuotesNew must be a linked table, and the query connect string must be empty.

JDBC PreparedStatement, UNION Select and parameter passing

Ok, I know the answer is simple and I'm going to feel pretty dumb but...
Java JDK 1.7, Sybase JDBC driver
Code snipit:
String sql = "select <blah>
from <blah blah>
where date1 = ?
UNION
select <blah>
from <blah blah>
where date2 = ?";
Connection conn = ConnectionManager.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql);
logger.info("parmemeter count: " + stmt.getParameterMetaData().getParameterCount());
stmt.setDate(1, new java.sql.Date(date.getTime()));
stmt.setDate(2, new java.sql.Date(date.getTime()));
ResultSet rs = stmt.executeQuery();
while rs.next()) {
// the rest of the code
}
So why is the parmeter count only 1?
Running the program throws an error complaining: java.sql.SQLException: Invalid parameter index 2.
If I reduce the sql to either piece and reduce the setDate() to only 1 it works just fine.
The SQL with the UNION runs just fine in an interactive sql session (? filled in with a date of course)
I just ran into this problem, and this thread was very helpful. It's not the union clause that's throwing errors; it's the date that you're passing in. If you're using to_date () (unclear from your code snippet), you need to be passing a string in the query (instead of a date). Good luck!

Strange error when use hive udf through jdbc client

all. I met a strange error when I use hive udf through jdbc client.
I have a udf to help me convert a string into time stamp format called reformat_date. I firstly execute ADD JAR and CREATE TEMPORARY FUNCTION, both work fine.
The SQL also can be explained in hive cli mode, and can be executed. But when use jdbc client, I got errors:
Query returned non-zero code: 10, cause:
FAILED: Error in semantic analysis: Line 1:283 Wrong arguments ''20121201000000'':
org.apache.hadoop.hive.ql.metadata.HiveException:
Unable to execute method public org.apache.hadoop.io.Text com.aa.datawarehouse.hive.udf.ReformatDate.evaluate(org.apache.hadoop.io.Text) on object com.aa.datawarehouse.hive.udf.ReformatDate#4557e3e8 of class com.aa.datawarehouse.hive.udf.ReformatDate with arguments {20121201000000:org.apache.hadoop.io.Text} of size 1:
at com.aa.statistic.dal.impl.TjLoginDalImpl.selectAwakenedUserCount(TjLoginDalImpl.java:258)
at com.aa.statistic.backtask.service.impl.UserBehaviorAnalysisServiceImpl.recordAwakenedUser(UserBehaviorAnalysisServiceImpl.java:326)
at com.aa.statistic.backtask.controller.BackstatisticController$21.execute(BackstatisticController.java:773)
at com.aa.statistic.backtask.controller.BackstatisticController$DailyExecutor.execute(BackstatisticController.java:823)
My SQL is
select count(distinct a.user_id) as cnt from ( select user_id, user_kind, login_date, login_time from tj_login_hive where p_month = '2012_12' and login_date = '20121201' and user_kind = '0' ) a join ( select user_id from tj_login_hive where p_month <= '2012_12' and datediff(to_date(reformat_date(concat('20121201', '000000'))), to_date(reformat_date(concat(login_date, '000000')))) >= 90 ) b on a.user_id = b.user_id
Thanks.
i think your udf threw exception.
if reformat_date function is that you make, you should check your logic.
if not, you should check the udf's specification.

Resources