[CONJ-146] result column splitting seems to fail (with BLOB's) Created: 2015-03-19  Updated: 2016-08-23  Resolved: 2016-08-23

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.1.6, 1.1.8
Fix Version/s: 1.3.6

Type: Bug Priority: Major
Reporter: Jaakko Kantojärvi Assignee: Georg Richter
Resolution: Cannot Reproduce Votes: 0
Labels: None
Environment:

MariaDB 10.0.17



 Description   

Trying to use mariadb connector/j with Atlassian Confluence. Adding plugins fail due to sql interaction error.

I added this change to code for better error reporting:

diff --git a/src/main/java/org/mariadb/jdbc/MySQLResultSet.java b/src/main/java/org/mariadb/jdbc/MySQLResultSet.java
index e612428..ef0d0a1 100644
--- a/src/main/java/org/mariadb/jdbc/MySQLResultSet.java
+++ b/src/main/java/org/mariadb/jdbc/MySQLResultSet.java
@@ -3462,7 +3462,11 @@ public class MySQLResultSet implements ResultSet {
     }
 
     public long getLong(int i) throws SQLException {
-        return getValueObject(i).getLong();
+        try {
+          return getValueObject(i).getLong();
+        } catch(Exception e) {
+          throw SQLExceptionMapper.getSQLException("Invalid value in field for getLong('" + this.queryResult.getColumnInformation()[i-1].getName() + "´') = " + getValueObject(i).getString(), "S1009", e);
+        }
     }
 
     public float getFloat(int i) throws SQLException {

And after that I get this in confluence log:

Caused by: java.sql.SQLException: Invalid value in field for getLong('PLUGINDA1_?') = ?l??^S??^_?,l?`????J?]?+?<??S??!?+(?^G^M?<65L?x????Y??*<^E?=?z?9s]?{???d???P??^???^\Kr????3?r^Vm{?Y?"^X?Fa(?5?cq???\??KFsEZ?L?^RdG<.?3^@^Do?E^G????^^?^^???ESC??z??6^?^Xa???Tx??Dx
?qd??9?????R7?D?7?TN?fR?4^GX?
        at org.mariadb.jdbc.internal.SQLExceptionMapper.getSQLException(SQLExceptionMapper.java:158)
        at org.mariadb.jdbc.MySQLResultSet.getLong(MySQLResultSet.java:3468)
        at org.mariadb.jdbc.MySQLResultSet.getLong(MySQLResultSet.java:170)
        at com.mchange.v2.c3p0.impl.NewProxyResultSet.getLong(NewProxyResultSet.java:2625)
        at net.sf.hibernate.type.LongType.get(LongType.java:21)
        at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:72)
        at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:63)
        at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:431)
        at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:205)
        at net.sf.hibernate.loader.Loader.doQuery(Loader.java:285)
        at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
        at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
        at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
        at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1570)
        at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
        at org.springframework.orm.hibernate.HibernateTemplate$24.doInHibernate(HibernateTemplate.java:875)
        at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:370)
        ... 129 more
Caused by: java.lang.NumberFormatException
        at java.math.BigDecimal.<init>(Unknown Source)
        at java.math.BigDecimal.<init>(Unknown Source)
        at org.mariadb.jdbc.internal.common.AbstractValueObject.getLong(AbstractValueObject.java:95)
        at org.mariadb.jdbc.MySQLResultSet.getLong(MySQLResultSet.java:3466)
        ... 145 more

The sql querye I beleave this is from is.

select plugindata0_.PLUGINDATAID as PLUGINDA1_, plugindata0_.PLUGINKEY as PLUGINKEY, plugindata0_.FILENAME as FILENAME, plugindata0_.LASTMODDATE as LASTMODD4_, plugindata0_.DATA as DATA from PLUGINDATA plugindata0_ where (plugindata0_.PLUGINKEY='fi.ayy.it.login' )

with

mysql confluence -e "select plugindata0_.PLUGINDATAID as PLUGINDA1_, plugindata0_.PLUGINKEY as PLUGINKEY, plugindata0_.FILENAME as FILENAME, plugindata0_.LASTMODDATE as LASTMODD4_, plugindata0_.DATA as DATA from PLUGINDATA plugindata0_ where (plugindata0_.PLUGINKEY='fi.ayy.it.login' );"

I get

 
+------------+-----------------+------------------------------------------+---------------------+------+
| PLUGINDA1_ | PLUGINKEY       | FILENAME                                 | LASTMODD4_          | DATA |
+------------+-----------------+------------------------------------------+---------------------+------+
|   20742150 | fi.ayy.it.login | plugin_4465232698427290254_login-0.1.jar | 2015-03-18 12:12:03 |      |
+------------+-----------------+------------------------------------------+---------------------+------+

(Though this seems to be without data, which is the one I manually inserted for testing purposes)

Table schema is

MariaDB [confluence]> describe PLUGINDATA;
+--------------+--------------+------+-----+---------+-------+
| Field        | Type         | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| PLUGINDATAID | bigint(20)   | NO   | PRI | NULL    |       |
| PLUGINKEY    | varchar(255) | NO   | UNI | NULL    |       |
| FILENAME     | varchar(255) | NO   | UNI | NULL    |       |
| LASTMODDATE  | datetime     | YES  |     | NULL    |       |
| DATA         | longblob     | YES  |     | NULL    |       |
+--------------+--------------+------+-----+---------+-------+



 Comments   
Comment by Vladislav Vaintroub [ 2015-05-31 ]

Can you repeat your bug with just JDBC code using your data and the queries you provided here
"Just JDBC" means no hibernate, ie
Statement.executeQuery and ResultSet.getLong and such

Comment by Jaakko Kantojärvi [ 2015-06-01 ]

It's bit hard now. I went with mysql with confluence and got the machine to production.

I'm just a confluence user (and mariadb with other applications). I tried to use mariadb with confluence, but confluence does something wrong or mariadb interface doesn't work (or fail to work) exactly like mysql one does. Also, I'm not fluent with Java.

There is related request for atlassian to support mariadb. So maybe they some day can provide more information about this. https://jira.atlassian.com/browse/CONF-29060 I'll link this to that issue too.

If you have time, the confluence was quite simple to setup with mariadb. Problem manifested in the enabling uplaoded plugins (any plugin).

Comment by Diego Dupin [ 2016-08-23 ]

closing this, since this JIRA is hosted with mariadb driver 1.3.6 without any problem ( see https://mariadb.org/eating-dog-food-running-jira-mariadb/)

Generated at Thu Feb 08 03:13:30 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.