You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by "Jon Frias (JIRA)" <em...@incubator.apache.org> on 2012/06/18 15:54:42 UTC

[jira] [Created] (EMPIREDB-147) BLOB datatype under empire 2.3.1-SNAPSHOT

Jon Frias created EMPIREDB-147:
----------------------------------

             Summary: BLOB datatype under empire 2.3.1-SNAPSHOT
                 Key: EMPIREDB-147
                 URL: https://issues.apache.org/jira/browse/EMPIREDB-147
             Project: Empire-DB
          Issue Type: Bug
          Components: Core
    Affects Versions: empire-db-2.3.1
         Environment: windows xp x64, using java 1.6.25, eclipse Id, postgreSQL database
            Reporter: Jon Frias
             Fix For: empire-db-2.1.0-incubating


Hi all, 

I am using the version 2.3.1-SNAPSHOT in my code and I found the following bug:

I have a datatable with 3 data fields (Integer, String and BLOB).

The database is created correctly with different data types, but when I am trying to get the information from the datatable executing commands, the following error is returned:

140 [main] INFO org.apache.empire.exceptions.EmpireException - An Error occured. Message is: The database operation failed. Native error is: Bad value for type long : \x01000100


The code I am using is the following (the BLOB data tye field is called "Information"):

/**
	 * Gets the address books.
	 *
	 * @return the address books
	 */
	public List<addressBookBean> getAddressBooks(){
		List<addressBookBean> myABs = new ArrayList<addressBookBean>();
				
		DBCommand cmd = db.createCommand();
		cmd.select(db.ADDRESSBOOK.ADDRESS_BOOK_ID, db.ADDRESSBOOK.LOCATION, db.ADDRESSBOOK.INFORMATION);
		
		DBReader reader = new DBReader();
		reader.open(cmd, conn);
		while(reader.moveNext()){
			myABs.add(new addressBookBean(
					reader.getInt(db.ADDRESSBOOK.ADDRESS_BOOK_ID),
					reader.getString(db.ADDRESSBOOK.LOCATION), 
					(byte[]) reader.getValue(db.ADDRESSBOOK.INFORMATION)));
		}
		
		return myABs;
	}

Thanks a lot for your time and if any further information is required, don't hesitate and let me know.

Best Regards,

Jon

PS: I opened an issue about a bug with the BLOB data type when the sql script is generated for creating the database. the error message was very similar and it was totally fixed. Maybe it can help. The issue is the following: 
https://issues.apache.org/jira/browse/EMPIREDB-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288425#comment-13288425



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (EMPIREDB-147) BLOB datatype under empire 2.3.1-SNAPSHOT

Posted by "Jon Frias (JIRA)" <em...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/EMPIREDB-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397375#comment-13397375 ] 

Jon Frias commented on EMPIREDB-147:
------------------------------------

Solved by overriding getResultValue method in the driver like this (suggested by Vladimir Lahoda):

    ...  driver = new DBDatabaseDriverPostgreSQL(){

                       @Override
                       public Object getResultValue(ResultSet rset,
int columnIndex, DataType dataType) throws SQLException {
                           if (dataType == DataType.BLOB){
                               InputStream is =
rset.getBinaryStream(columnIndex);
                               if (is == null){
                                   return new byte[]{};
                               }
                               try{
                                   return ByteStreams.toByteArray(is);
 //Google Guava utility method
                               }catch (Exception e) {
                                   LOG.log(Level.SEVERE, "",e);  //JDK logging
                                   return new byte[]{};
                               }
                               finally{
                                   if (is != null)
                                       try {
                                           is.close();
                                       } catch (Exception e) {}
                               }
                           } else{
                               return super.getResultValue(rset,
columnIndex, dataType);
                           }
                       }

                   };

                
> BLOB datatype under empire 2.3.1-SNAPSHOT
> -----------------------------------------
>
>                 Key: EMPIREDB-147
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-147
>             Project: Empire-DB
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: empire-db-2.3.1
>         Environment: windows xp x64, using java 1.6.25, eclipse Id, postgreSQL database
>            Reporter: Jon Frias
>              Labels: feature
>             Fix For: empire-db-2.1.0-incubating
>
>
> Hi all, 
> I am using the version 2.3.1-SNAPSHOT in my code and I found the following bug:
> I have a datatable with 3 data fields (Integer, String and BLOB).
> The database is created correctly with different data types, but when I am trying to get the information from the datatable executing commands, the following error is returned:
> 140 [main] INFO org.apache.empire.exceptions.EmpireException - An Error occured. Message is: The database operation failed. Native error is: Bad value for type long : \x01000100
> The code I am using is the following (the BLOB data tye field is called "Information"):
> /**
> 	 * Gets the address books.
> 	 *
> 	 * @return the address books
> 	 */
> 	public List<addressBookBean> getAddressBooks(){
> 		List<addressBookBean> myABs = new ArrayList<addressBookBean>();
> 				
> 		DBCommand cmd = db.createCommand();
> 		cmd.select(db.ADDRESSBOOK.ADDRESS_BOOK_ID, db.ADDRESSBOOK.LOCATION, db.ADDRESSBOOK.INFORMATION);
> 		
> 		DBReader reader = new DBReader();
> 		reader.open(cmd, conn);
> 		while(reader.moveNext()){
> 			myABs.add(new addressBookBean(
> 					reader.getInt(db.ADDRESSBOOK.ADDRESS_BOOK_ID),
> 					reader.getString(db.ADDRESSBOOK.LOCATION), 
> 					(byte[]) reader.getValue(db.ADDRESSBOOK.INFORMATION)));
> 		}
> 		
> 		return myABs;
> 	}
> Thanks a lot for your time and if any further information is required, don't hesitate and let me know.
> Best Regards,
> Jon
> PS: I opened an issue about a bug with the BLOB data type when the sql script is generated for creating the database. the error message was very similar and it was totally fixed. Maybe it can help. The issue is the following: 
> https://issues.apache.org/jira/browse/EMPIREDB-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288425#comment-13288425

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Reopened] (EMPIREDB-147) BLOB datatype under empire 2.3.1-SNAPSHOT

Posted by "Francis De Brabandere (JIRA)" <em...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/EMPIREDB-147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Francis De Brabandere reopened EMPIREDB-147:
--------------------------------------------

      Assignee: Francis De Brabandere

Reopening as I want to properly fix this in the driver.

Thanks for the fix!
                
> BLOB datatype under empire 2.3.1-SNAPSHOT
> -----------------------------------------
>
>                 Key: EMPIREDB-147
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-147
>             Project: Empire-DB
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: empire-db-2.3.1
>         Environment: windows xp x64, using java 1.6.25, eclipse Id, postgreSQL database
>            Reporter: Jon Frias
>            Assignee: Francis De Brabandere
>              Labels: feature
>             Fix For: empire-db-2.1.0-incubating
>
>
> Hi all, 
> I am using the version 2.3.1-SNAPSHOT in my code and I found the following bug:
> I have a datatable with 3 data fields (Integer, String and BLOB).
> The database is created correctly with different data types, but when I am trying to get the information from the datatable executing commands, the following error is returned:
> 140 [main] INFO org.apache.empire.exceptions.EmpireException - An Error occured. Message is: The database operation failed. Native error is: Bad value for type long : \x01000100
> The code I am using is the following (the BLOB data tye field is called "Information"):
> /**
> 	 * Gets the address books.
> 	 *
> 	 * @return the address books
> 	 */
> 	public List<addressBookBean> getAddressBooks(){
> 		List<addressBookBean> myABs = new ArrayList<addressBookBean>();
> 				
> 		DBCommand cmd = db.createCommand();
> 		cmd.select(db.ADDRESSBOOK.ADDRESS_BOOK_ID, db.ADDRESSBOOK.LOCATION, db.ADDRESSBOOK.INFORMATION);
> 		
> 		DBReader reader = new DBReader();
> 		reader.open(cmd, conn);
> 		while(reader.moveNext()){
> 			myABs.add(new addressBookBean(
> 					reader.getInt(db.ADDRESSBOOK.ADDRESS_BOOK_ID),
> 					reader.getString(db.ADDRESSBOOK.LOCATION), 
> 					(byte[]) reader.getValue(db.ADDRESSBOOK.INFORMATION)));
> 		}
> 		
> 		return myABs;
> 	}
> Thanks a lot for your time and if any further information is required, don't hesitate and let me know.
> Best Regards,
> Jon
> PS: I opened an issue about a bug with the BLOB data type when the sql script is generated for creating the database. the error message was very similar and it was totally fixed. Maybe it can help. The issue is the following: 
> https://issues.apache.org/jira/browse/EMPIREDB-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288425#comment-13288425

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (EMPIREDB-147) BLOB datatype under empire 2.3.1-SNAPSHOT

Posted by "Francis De Brabandere (JIRA)" <em...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/EMPIREDB-147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Francis De Brabandere resolved EMPIREDB-147.
--------------------------------------------

       Resolution: Fixed
    Fix Version/s: empire-db-2.3.1

Fixed by reading bytes instead of blob
                
> BLOB datatype under empire 2.3.1-SNAPSHOT
> -----------------------------------------
>
>                 Key: EMPIREDB-147
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-147
>             Project: Empire-DB
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: empire-db-2.3.0
>         Environment: windows xp x64, using java 1.6.25, eclipse Id, postgreSQL database
>            Reporter: Jon Frias
>            Assignee: Francis De Brabandere
>              Labels: feature
>             Fix For: empire-db-2.3.1
>
>
> Hi all, 
> I am using the version 2.3.1-SNAPSHOT in my code and I found the following bug:
> I have a datatable with 3 data fields (Integer, String and BLOB).
> The database is created correctly with different data types, but when I am trying to get the information from the datatable executing commands, the following error is returned:
> 140 [main] INFO org.apache.empire.exceptions.EmpireException - An Error occured. Message is: The database operation failed. Native error is: Bad value for type long : \x01000100
> The code I am using is the following (the BLOB data tye field is called "Information"):
> /**
> 	 * Gets the address books.
> 	 *
> 	 * @return the address books
> 	 */
> 	public List<addressBookBean> getAddressBooks(){
> 		List<addressBookBean> myABs = new ArrayList<addressBookBean>();
> 				
> 		DBCommand cmd = db.createCommand();
> 		cmd.select(db.ADDRESSBOOK.ADDRESS_BOOK_ID, db.ADDRESSBOOK.LOCATION, db.ADDRESSBOOK.INFORMATION);
> 		
> 		DBReader reader = new DBReader();
> 		reader.open(cmd, conn);
> 		while(reader.moveNext()){
> 			myABs.add(new addressBookBean(
> 					reader.getInt(db.ADDRESSBOOK.ADDRESS_BOOK_ID),
> 					reader.getString(db.ADDRESSBOOK.LOCATION), 
> 					(byte[]) reader.getValue(db.ADDRESSBOOK.INFORMATION)));
> 		}
> 		
> 		return myABs;
> 	}
> Thanks a lot for your time and if any further information is required, don't hesitate and let me know.
> Best Regards,
> Jon
> PS: I opened an issue about a bug with the BLOB data type when the sql script is generated for creating the database. the error message was very similar and it was totally fixed. Maybe it can help. The issue is the following: 
> https://issues.apache.org/jira/browse/EMPIREDB-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288425#comment-13288425

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (EMPIREDB-147) BLOB datatype under empire 2.3.1-SNAPSHOT

Posted by "Francis De Brabandere (JIRA)" <em...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/EMPIREDB-147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Francis De Brabandere updated EMPIREDB-147:
-------------------------------------------

    Affects Version/s:     (was: empire-db-2.3.1)
                       empire-db-2.3.0
        Fix Version/s:     (was: empire-db-2.1.0-incubating)
    
> BLOB datatype under empire 2.3.1-SNAPSHOT
> -----------------------------------------
>
>                 Key: EMPIREDB-147
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-147
>             Project: Empire-DB
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: empire-db-2.3.0
>         Environment: windows xp x64, using java 1.6.25, eclipse Id, postgreSQL database
>            Reporter: Jon Frias
>            Assignee: Francis De Brabandere
>              Labels: feature
>             Fix For: empire-db-2.3.1
>
>
> Hi all, 
> I am using the version 2.3.1-SNAPSHOT in my code and I found the following bug:
> I have a datatable with 3 data fields (Integer, String and BLOB).
> The database is created correctly with different data types, but when I am trying to get the information from the datatable executing commands, the following error is returned:
> 140 [main] INFO org.apache.empire.exceptions.EmpireException - An Error occured. Message is: The database operation failed. Native error is: Bad value for type long : \x01000100
> The code I am using is the following (the BLOB data tye field is called "Information"):
> /**
> 	 * Gets the address books.
> 	 *
> 	 * @return the address books
> 	 */
> 	public List<addressBookBean> getAddressBooks(){
> 		List<addressBookBean> myABs = new ArrayList<addressBookBean>();
> 				
> 		DBCommand cmd = db.createCommand();
> 		cmd.select(db.ADDRESSBOOK.ADDRESS_BOOK_ID, db.ADDRESSBOOK.LOCATION, db.ADDRESSBOOK.INFORMATION);
> 		
> 		DBReader reader = new DBReader();
> 		reader.open(cmd, conn);
> 		while(reader.moveNext()){
> 			myABs.add(new addressBookBean(
> 					reader.getInt(db.ADDRESSBOOK.ADDRESS_BOOK_ID),
> 					reader.getString(db.ADDRESSBOOK.LOCATION), 
> 					(byte[]) reader.getValue(db.ADDRESSBOOK.INFORMATION)));
> 		}
> 		
> 		return myABs;
> 	}
> Thanks a lot for your time and if any further information is required, don't hesitate and let me know.
> Best Regards,
> Jon
> PS: I opened an issue about a bug with the BLOB data type when the sql script is generated for creating the database. the error message was very similar and it was totally fixed. Maybe it can help. The issue is the following: 
> https://issues.apache.org/jira/browse/EMPIREDB-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288425#comment-13288425

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (EMPIREDB-147) BLOB datatype under empire 2.3.1-SNAPSHOT

Posted by "Francis De Brabandere (JIRA)" <em...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/EMPIREDB-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13421437#comment-13421437 ] 

Francis De Brabandere commented on EMPIREDB-147:
------------------------------------------------

More related info here:
http://stackoverflow.com/questions/2069541/postgresql-jdbc-and-streaming-blobs

It seems that pgsql supports some kind of external LargeObject API but this is not what we are using, that's why getBlob fails, it tries to fetch the result into Long external OID.

2 options:
stick with BYTEA and use the provided patch but the simpler with rset.getBytes(columnIndex)
Alternatively we could  use the LargeObject API to store the file

Both ways explained here
http://jdbc.postgresql.org/documentation/84/binary-data.html

I suggest we stick to BYTEA for now until somebody comes uw with a LargeObject API patch (which would force us out of the jdbc spec and add a dependency to the postgresql driver)

                
> BLOB datatype under empire 2.3.1-SNAPSHOT
> -----------------------------------------
>
>                 Key: EMPIREDB-147
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-147
>             Project: Empire-DB
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: empire-db-2.3.1
>         Environment: windows xp x64, using java 1.6.25, eclipse Id, postgreSQL database
>            Reporter: Jon Frias
>            Assignee: Francis De Brabandere
>              Labels: feature
>             Fix For: empire-db-2.1.0-incubating
>
>
> Hi all, 
> I am using the version 2.3.1-SNAPSHOT in my code and I found the following bug:
> I have a datatable with 3 data fields (Integer, String and BLOB).
> The database is created correctly with different data types, but when I am trying to get the information from the datatable executing commands, the following error is returned:
> 140 [main] INFO org.apache.empire.exceptions.EmpireException - An Error occured. Message is: The database operation failed. Native error is: Bad value for type long : \x01000100
> The code I am using is the following (the BLOB data tye field is called "Information"):
> /**
> 	 * Gets the address books.
> 	 *
> 	 * @return the address books
> 	 */
> 	public List<addressBookBean> getAddressBooks(){
> 		List<addressBookBean> myABs = new ArrayList<addressBookBean>();
> 				
> 		DBCommand cmd = db.createCommand();
> 		cmd.select(db.ADDRESSBOOK.ADDRESS_BOOK_ID, db.ADDRESSBOOK.LOCATION, db.ADDRESSBOOK.INFORMATION);
> 		
> 		DBReader reader = new DBReader();
> 		reader.open(cmd, conn);
> 		while(reader.moveNext()){
> 			myABs.add(new addressBookBean(
> 					reader.getInt(db.ADDRESSBOOK.ADDRESS_BOOK_ID),
> 					reader.getString(db.ADDRESSBOOK.LOCATION), 
> 					(byte[]) reader.getValue(db.ADDRESSBOOK.INFORMATION)));
> 		}
> 		
> 		return myABs;
> 	}
> Thanks a lot for your time and if any further information is required, don't hesitate and let me know.
> Best Regards,
> Jon
> PS: I opened an issue about a bug with the BLOB data type when the sql script is generated for creating the database. the error message was very similar and it was totally fixed. Maybe it can help. The issue is the following: 
> https://issues.apache.org/jira/browse/EMPIREDB-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288425#comment-13288425

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (EMPIREDB-147) BLOB datatype under empire 2.3.1-SNAPSHOT

Posted by "Jon Frias (JIRA)" <em...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/EMPIREDB-147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jon Frias resolved EMPIREDB-147.
--------------------------------

    Resolution: Fixed

Although the solution is valid and fixes the problem, from my point of view, this issue should be taken into account for future developments.

Thanks for your support!

Jon
                
> BLOB datatype under empire 2.3.1-SNAPSHOT
> -----------------------------------------
>
>                 Key: EMPIREDB-147
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-147
>             Project: Empire-DB
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: empire-db-2.3.1
>         Environment: windows xp x64, using java 1.6.25, eclipse Id, postgreSQL database
>            Reporter: Jon Frias
>              Labels: feature
>             Fix For: empire-db-2.1.0-incubating
>
>
> Hi all, 
> I am using the version 2.3.1-SNAPSHOT in my code and I found the following bug:
> I have a datatable with 3 data fields (Integer, String and BLOB).
> The database is created correctly with different data types, but when I am trying to get the information from the datatable executing commands, the following error is returned:
> 140 [main] INFO org.apache.empire.exceptions.EmpireException - An Error occured. Message is: The database operation failed. Native error is: Bad value for type long : \x01000100
> The code I am using is the following (the BLOB data tye field is called "Information"):
> /**
> 	 * Gets the address books.
> 	 *
> 	 * @return the address books
> 	 */
> 	public List<addressBookBean> getAddressBooks(){
> 		List<addressBookBean> myABs = new ArrayList<addressBookBean>();
> 				
> 		DBCommand cmd = db.createCommand();
> 		cmd.select(db.ADDRESSBOOK.ADDRESS_BOOK_ID, db.ADDRESSBOOK.LOCATION, db.ADDRESSBOOK.INFORMATION);
> 		
> 		DBReader reader = new DBReader();
> 		reader.open(cmd, conn);
> 		while(reader.moveNext()){
> 			myABs.add(new addressBookBean(
> 					reader.getInt(db.ADDRESSBOOK.ADDRESS_BOOK_ID),
> 					reader.getString(db.ADDRESSBOOK.LOCATION), 
> 					(byte[]) reader.getValue(db.ADDRESSBOOK.INFORMATION)));
> 		}
> 		
> 		return myABs;
> 	}
> Thanks a lot for your time and if any further information is required, don't hesitate and let me know.
> Best Regards,
> Jon
> PS: I opened an issue about a bug with the BLOB data type when the sql script is generated for creating the database. the error message was very similar and it was totally fixed. Maybe it can help. The issue is the following: 
> https://issues.apache.org/jira/browse/EMPIREDB-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288425#comment-13288425

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira