Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:37:15+00:00 2026-06-07T16:37:15+00:00

I have troubles saving a byte array to my Informix database, I’ll show you

  • 0

I have troubles saving a byte array to my Informix database, I’ll show you how I’m trying:

In Fichero.java among other things I have this:

@Column(name="fichero", columnDefinition="blob")
private byte[] contenido;

I had to do that way because I can’t get Informix+Hibernate to accept @Lob annotation (yes, I tried that extending Hibernate’s dialect workaround but it doesn’t work for me)

Then I read a file and convert it to a bytearray this way:
FileManager.java

private byte[] fromFile2ByteArray(String nombreFichero) throws FileNotFoundException, IOException{
   File file = new File(nombreFichero);
   InputStream is = new FileInputStream(file);
   byte[] contenido = new byte[(int)file.length()];
   is.read(contenido);
   is.close();
   return contenido;
}

And next I try to save it to my database using:
FicheroDAO.java

public void save(Object object) {
   getHibernateTemplate().save(object);      
}

where the object is my Fichero object.

Buuuuut, I get the following exception.

Hibernate: 
    /* insert es.cosas.modelo.datos.dominio.fichero.Fichero
        */ insert 
        into
            cosas_fichero
            (fichero, idEnvio, nombrefichero, respuesta) 
        values
            (?, ?, ?, ?)
WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: -841, SQLState: S0000
ERROR: org.hibernate.util.JDBCExceptionReporter - Name must start with a letter or '_' and contain letters, digits, or '_'.
22-jun-2012 9:25:32 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() para servlet Spring MVC Dispatcher Servlet lanzó excepción
java.sql.SQLException: Name must start with a letter or '_' and contain letters, digits, or '_'.
   at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:379)
   at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3109)
   at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3419)
   at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2282)
   at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2202)
   at com.informix.jdbc.IfxSqli.executeFastPath(IfxSqli.java:5475)
   at com.informix.jdbc.IfxSqli.executeFastPath(IfxSqli.java:5400)
   at com.informix.jdbc.IfxSmartBlob.IfxLoColInfo(IfxSmartBlob.java:306)
   at com.informix.jdbc.IfxSmBlob.createSmartLob(IfxSmBlob.java:751)
   at com.informix.jdbc.IfxSmBlob.createBlobOnServer(IfxSmBlob.java:497)
   at com.informix.jdbc.IfxResultSet.executeUpdate(IfxResultSet.java:301)
   at com.informix.jdbc.IfxStatement.executeUpdateImpl(IfxStatement.java:885)
   at com.informix.jdbc.IfxPreparedStatement.executeUpdate(IfxPreparedStatement.java:279)
   at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
   at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
   at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:57)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2329)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2836)
   at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:267)
   at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
   at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
   at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
   at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
   at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
   at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:705)
   at org.hibernate.impl.SessionImpl.save(SessionImpl.java:693)
   at org.hibernate.impl.SessionImpl.save(SessionImpl.java:689)
   at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:686)
   at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:1)
   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
   at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
   at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:683)

The next line in the exception points to FicheroDAO.java file and the line number where it tries to save the object…

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:37:16+00:00Added an answer on June 7, 2026 at 4:37 pm

    Well in the end I figured out a more simple workaround: I just defined the column in the DB as byte… and it works like a charm… Thanx anyway..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have troubles with the following database design (simplified for the example). It allows
I have troubles using a foreign protocol in Objective-C. Is there any other solution
I have some troubles mapping a JSON Array to RestKit. This is what the
I have some troubles with saving a image from memorystream. Here is my code:
I have trouble saving my date field into database using CakePHP. Table column name
I'm having nice first days using Yii but have some troubles with getting things
I have some trouble, saving values from input stream (cin) into an array. int
I am having trouble saving my entities to the database using EntityFramework. I have
I have troubles animating a StackPanel with the VisualStateManager . VisualStateManager.GoToState() accepts a Control
I'm writing an MPI C program. I have troubles debugging it, because whenever I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.