-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieving data Encountered unexpected unknown token #770
Comments
Hi @anddo88 I tried reproducing your usecase with above table structure and randomized data in all columns (no null data), but I couldn't reproduce the error reading directly from driver side. I too tested with different drivers (6.2.2, 6.4.0) with jdk1.7.0_80_x64, but no luck. The error you specified, is coming from the driver. And it looks like the connection is dropping during reading this data. As you see "The connection is closed" is a
|
Hi cheena, Thank you for your response. Connection is closed while retrieving a row after the last row has (for some reason) closed the connection. Here is a sample insert for one row as we made the column in question () equals null in all rows INSERT INTO incoming_correspondence (version_Id,IncomingNo,Date,ExtEntityOutgoingNo,ExtDate,IncomingType,ExternalEntity,barcode,ExternalEntityCode,RoutingSource,ElectronicDesc,OriginalSourceUnit,Routing,OtherRouting,correspondent,attachmentsDesc,incomingDeliveryMethod,concernedState,concernedStateOptions,original_paper_code,test_field,corr_status,signature,attachments) VALUES(50641,null,2458331.50000,null,null,'190','102',null,'102','100',null,null,'أخرى',null,null,null,null,'جمهورية كوريا الجنوبية','180',null,null,null,'696d6167652f6a7369676e61747572653b6261736533302c32495a3232303059333536366561383833343566696863335a32353535376663636662383739626864383359326b5f314a5a333661393535303059646563383231305a36613838353632313030593638383935333130305a343432323330','ff'); The columns in question are
No. I will walk in this scenario but it will take time as the application is not small one
Here is a sample and you can repeat that row and as you see the last column might even got data inserted manually to reproduce the issue. However, I don't know what's exactly might cause the problem so I am not sure of reproduction of the case of course INSERT INTO incoming_correspondence (version_Id,IncomingNo,Date,ExtEntityOutgoingNo,ExtDate,IncomingType,ExternalEntity,barcode,ExternalEntityCode,RoutingSource,ElectronicDesc,OriginalSourceUnit,Routing,OtherRouting,correspondent,attachmentsDesc,incomingDeliveryMethod,concernedState,concernedStateOptions,original_paper_code,test_field,corr_status,signature,attachments) VALUES(50641,null,2458331.50000,null,null,'190','102',null,'102','100',null,null,'أخرى',null,null,null,null,'جمهورية كوريا الجنوبية','180',null,null,null,'696d6167652f6a7369676e61747572653b6261736533302c32495a3232303059333536366561383833343566696863335a32353535376663636662383739626864383359326b5f314a5a333661393535303059646563383231305a36613838353632313030593638383935333130305a343432323330','ff'); Again, thank you :) |
OK there is an update, after trying to convert hibernate hql query to sql query using JDBC directly, the following exception occurs which is pretty similar to the previous one specially in
|
Hi @anddo88 This error is different than before as it says |
Here it is the java code and the query is commented below public Object findById(final CmsTemplateModel correspondnce,final Long versionId) throws IllegalStateException , IllegalArgumentException
{
final HashMap<String, Object> map = new HashMap<String, Object>();
try {
Connection connection = hibernateSession.doReturningWork(new ReturningWork<Connection>() {
@Override
public Connection execute(Connection conn) throws SQLException {
return conn;
}
});
// This is the query which is for example
// select * from incoming_correspondence where version_id = 5027
String queryStr= "select * from " + ""+correspondnce.getInternalName() + " where version_id = " +versionId ;
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(queryStr);
ResultSetMetaData meta = rs.getMetaData();
while(rs.next())
{
for (int i = 1; i <= meta.getColumnCount(); i++) {
String key = meta.getColumnName(i);
int type=meta.getColumnType(i);
map.put(key, getSqlType(rs, key, type));
}
}
}
catch(Exception ex) {
ex.printStackTrace();
}
return map;
} I also tried to close the resultset after the while loop and the statement too but still same error. The common between to issues is the |
Hi @anddo88 I've tried to reproduce your scenario, but I don't get any problem in reading the data from any column iteratively. In your sample code above, I see you're trying to read data from a row and processing it. I've uploaded a gist to reproduce your data/scenario, please confirm running this code works for you in your environment, and if you can modify and make it fail, I can then try to look into the cause. |
OK I'll test this and reply as soon as possible |
Hi @anddo88 |
Closing due to inactivity |
If anytone else finds this, it seem he found the solution here https://stackoverflow.com/a/52748707/1362043. |
Driver version or jar name
Tried 6.4.0, 6.2.2 and 6.2.1
SQL Server version
Microsoft SQL Server 2014 - 12.0.2000.8 (X64)
Client operating system
Windows Server 2012
Java/JVM version
java version "1.7.0", Oracle
Table schema
CREATE TABLE "dbo"."incoming_correspondence" (
"version_Id" bigint NOT NULL,
"IncomingNo" varchar(100) NULL,
"Date" decimal(18,5) NULL,
"ExtEntityOutgoingNo" varchar(50) NULL,
"ExtDate" decimal(18,5) NULL,
"IncomingType" varchar(50) NULL,
"ExternalEntity" varchar(50) NULL,
"barcode" varchar(100) NULL,
"ExternalEntityCode" varchar(50) NULL,
"RoutingSource" varchar(50) NULL,
"ElectronicDesc" varchar(4000) NULL,
"OriginalSourceUnit" varchar(50) NULL,
"Routing" varchar(1024) NULL,
"OtherRouting" varchar(50) NULL,
"correspondent" varchar(100) NULL,
"attachmentsDesc" varchar(4000) NULL,
"incomingDeliveryMethod" varchar(50) NULL,
"concernedState" varchar(50) NULL,
"concernedStateOptions" varchar(50) NULL,
"original_paper_code" varchar(50) NULL,
"test_field" varchar(50) NULL,
"corr_status" varchar(1024) NULL,
"signature" varbinary(max) NULL,
"attachments" varchar(50) NULL,
CONSTRAINT "PK__name_inco__07A684B1737A6C8B" PRIMARY KEY CLUSTERED("version_Id")
ON [PRIMARY]);
Problem description
Using c3p0 0.9.2.1, hibernate 4.2.21, JBoss AS 7.1.1 and connecting with Microsoft SQL Server 2014 - 12.0.2000.8 (X64).
mssql-jdbc 6.2.2 (I tested 6.4.0 for doubt but we are using 6.2.2) is used for JRE7 support.
Scenario
Retrieving data from a table as multiple rows but NOT at once. It's simply a loop and each time a row retrieved and finally they put in HashMap.
Problem & Output
After long investigation and debugging I found out that the problem scope related with two columns in the table. One is VARBINARY(MAX) called signature and the other is VARCHAR(1024) called status. If both of these columns have a value on a row, this exception occurs on retrieving the next row. If any of them is set to null, all is good. No matter the length of the value in them.
Tries so far
org.hibernate.session
object methodsisConnected()
andisOpen()
and until the exception is thrown, the output was alwaystrue
for bothQuestions
What does that exception means ? Specially that sql server logging doesn't show anything about it !!
Why it's happening and what might be the cause of this ?
Expected behavior and actual behavior
To parse/retrieve fields correctly and successfully
Repro code
I'm not sure how that possible since I do not know the main reason for the issue and we have been facing this issue for long time now (about more than week) and were at the beginning are struggling to reproduce such issue on our local environments.
The text was updated successfully, but these errors were encountered: