Using Blobs with MySQL

Hi,
I've posted a few thread semi-related to this, and decided I would just ask a more general question.
Has anyone been able to save (& load) BLOBs in MySQL using ADF BC? If so, how did you do it?

No, its not the same as doing this process with Oracle.
First of all, I cannot use BlobDomain, and instead I have to use something else that implements java.sql.Blob. I would use the one from the mysql driver, but it has private constructors....
So I tried to use SerialBlob, then cast it to java.sql.Blob before committing to the db, and after some efforts I was able to finally save a Blob to my table.
However, every time I try and load the blob again into my Entity Object, I am getting index out of bounds exceptions.
(Even when I inserted a blob using PreparedStatements, then tried to have ADF BC retrieve the blob from the db)

Similar Messages

  • About using hibernate with mysql

    hi all,
    i have used hibernate with hsqldb(database given by default) and it works fine.but when i tried to use it with mysql then i have encountered a problem
    xception
    org.hibernate.TransactionException: Transaction not successfully started
         org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:149)
         events.EventManagerServlet.doGet(EventManagerServlet.java:63)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    though i have put jar file of mysql in lib directory and changed the driver name in hibernate.cfg.xml.
    can any one place some example illustrating the steps involving.thanx

    Hi smogura,
    Thanks for the message. Ok I did as you told. I believe I went to the right place:
    Resource->JDBC Connection pools. However I wasn't sure how exactly to go about setting connection pools,
    so I went to the web and did a search and I managed to get hold of this
    website:http://www.albeesonline.com/blog/2008/08/06/creating-and-configuring-a-mysql-datasource-in-
    glassfish-application-server/
    I followed from steps 4 onwards. However at step 14, I did not get a sucesfull ping. The values I used are as follows:
    General:
    Name:               MySQL
    Datasource Classname:     com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
    Resource Type:           javax.sql.ConnectionPoolDataSource
    Advanced Properties:
    databaseName:      ebooking
    ServerName:     GlassFish
    URL          jdbc:mysql://localhost:3306/ebooking
    password          *****
    user:          1234
    I am not sure what is wrong, by the way, I am using Glassfish V3 that comes bundled with netbeans. Any idea what's wrong or missing? Thanks
    regards

  • How use Tomcat with MySQL

    Can anybody suggest me as how to use Tomcat with MySQL server.
    Thanks in advance.
    Khiz_eng

    add the classpath to the JDBC-driver to the tomcat-
    environment (I did it in tomcat.sh)
    Then put your code accessing MySQL into a servlet....
    You can put the user-ID and the password into a session-
    object or read them in as parameters.
    The book 'core Servlets and Java Server Pages' from
    Marty Hall gave me a lot information.
    Regards
    Fredy

  • Using java with mysql JDBC

    Hello
    I'm trying to write a program which reads in tab-delimeted text files and then stores the results in a mysql database. The files are roughly 20,000 lines long and can have up to 10 columns, so for the biggest files I have 200,000 pieces of data to be stored seperately in the database.
    I'm currently using the readLine() method of bufferedreader, then using the split function to seperate the string into tokens. The problem is that it seems to be very slow. It is a lot of information, and im not running it on a very fast machine, but even so im sure there must be a more efficient way of acheiving this.
    Here's some of my code:
    BufferedReader in = new BufferedReader(new FileReader("test.res"));
    while((result = in.readLine()) != null) {
    result = in.readLine();
    aLine = result.split("\t");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[0] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[1] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[2] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[3] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[4] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[5] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[6] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[7] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[8] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[9] +"')");
    I would appreciate any advice thanks.
    PS this is the first time ive tried anything like this so im probably missing something obvious.

    Form the example you have chosen it seems to me, that your table only has one column (words) and that you have multiple value entries for that column in one line of your text file ?!
    That is strange. Normaly I would assume (like the other answers indicate) that you have several columns and that each line in your text file has n values each for a different column.
    Have look at PreparedStatement.
    // the name of your connection is con, you have six columns named col1 to col6 and six entries per line, All six are strings...
    PreparedStatement pstmt = con.prepareStatement("insert into test (col1 , col2 , col3,col4,col5,col6) values( ? , ? , ? , ? , ? , ?)") ;
    BufferedReader in = new BufferedReader(new FileReader("test.res"));
    while((result = in.readLine()) != null) {
       result = in.readLine();
       aLine = result.split("\t");
       for (int i = 0 ; i < 6 ; i++) {
           pstmt.setString((i+1),aLine) ;
    pstmt.executeUpdate() ;
    But this is still not the fastest approach. MySQL supports bulk imports
    Have look at this feature. Maybe the fastest way is to 'convert' the textfile into something like a MySQL dump an than process it using it the MySQL import features.

  • Nullpointerexception when using servlet with Mysql on a cobalt Raq3 Server

    I'm a student and i have to use servlets and Mysql to make a Database application. Our school has a Cobalt Raq3 server and has installed Java Dev Kit 1.3a.
    First problem they can't tell me their driver manager for Mysql.
    Second problem when i try my servlet it gives a NullpointerException
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class Testingo2 extends HttpServlet {
    // Hier word een Statement en Connectie object aangemaakt die later zullen worden gebruikt om een database aan te spreken
    Statement stm;
    Connection con;
         // Hier word de servlet geinitialiseerd
    public void init() throws ServletException {
         try {
              // Hier wordt de database driver geladen
              Class.forName("org.gjt.mm.mysql.Driver");
              /** Hier gaan we gebruik maken van het Connection Object om verbinding te maken met de database CFP door een           * jdbc.odbc bridge en dit zonder username en passwoord
              con = DriverManager.getConnection("jdbc:mysql://cfp.ehsal.be:3306/cfp","bjorn","disaronno");
              // Hier zorgen we ervoor dat als er een zich een fout voordoet dat deze getoond wordt
                   catch (ClassNotFoundException cnfe ) {
                   System.out.println(cnfe.toString());
                   catch (SQLException e) {
                   System.out.println(e.toString());
    // Als de servlet het einde van zijn levenscyclus heeft bereikt gaat het connectie object worden afgesloten
    public void destroy() {
         try { con.close();}
         catch (SQLException e) {}
    public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    try {
         /** Hier gaat men met het Connectie object een statement aanmaken,welk dan later zal worden gebruikt voor het           * uitvoeren van query's
         stm = con.createStatement();
         /** Hier gaat men de query "selecteer alles van de tabel projecten" uitvoeren op de cfp database dankzij het      * statement en connection object. Deze gegevens worden dan opgeslagen in de Resultset rs.
         ResultSet rs = stm.executeQuery("SELECT project,land,titel,omschrijving,budget,informatie FROM PROJECTEN ");
         /** Hier gaat men informatie, over de gegevens die in de ResultSet rs zijn opgeslagen, opslaan in ResultSetMetaData      * meta.
         ResultSetMetaData meta = rs.getMetaData();
         // Hiergaat men het aantal kolommen van de tabel tellen en opslagen in de Integer kolom
         int kolom;
         kolom = meta.getColumnCount();
         // Hier declareerd men welk soort meta type we naar browser sturen, hier dus HTML tekst
         res.setContentType("text/html");
         // Hier gaan we een PrintWriter object out aanmaken dat gebruikt zal worden om de html tekst naar de client te sturen
         PrintWriter out = res.getWriter();
         // De basis html code voor deze pagina
         out.println("<HTML >");
         out.println("<BODY BGCOLOR =fd8017>");
         out.println("<H1> <B><CENTER><FONT COLOR='#00008b'> Overzicht van de projecten </FONT></CENTER></B></H1>");
         /** Hier defini�ren we een tabel die van de hoogte en breedte van het scherm volledig gebruik maakt, waarvan de boord      * van de tabel een dikte van 1 heeft, de ruimte tussen de cellen in de tabel en tussen de randen van een cel en de      * inhoud is gelijk aan 2 (in pixels) en een achtergrondkleur fd8017
         out.println("<TABLE HEIGHT='100%' WIDTH='100%' BORDER=1 CELLPADDING = 2 CELLSPACING = 2 BGCOLOR =fd8017>");
              // begintag voor een nieuwe rij
              out.println("<TR>");
              /** Hier creeren we een lus om de kolom hoofden naar de client te sturen. Deze lus begint als j=1 en gaat           * door tot j = aantal kolommen en na elke loop wordt j verhoogd met 1. Normaal werden alle kolom hoofden           * uit de database opgehaald en afgebeeld, maar vermits MySQL geen kolom hoofden aanvaard waar spaties           * inzitten heb ik gekozen om hier de kolom hoofden die uit meer dan 1 woord bestaan op te halen en aan te           * passen. Dit voor estetische redenen, voor het functioneren van de servlet heeft dit echter geen belang
    for(int j=1;j<=kolom;j++){
              if (meta.getColumnName(j).equals("project")) {
              out.println("<TH><FONT COLOR='#00008b'> project nr </TH>");
              else if (meta.getColumnName(j).equals("budget")) {
              out.println("<TH><FONT COLOR='#00008b'> budget (in 1000 �) </TH>");
              else if (meta.getColumnName(j).equals("informatie")) {
              out.println("<TH><FONT COLOR='#00008b'> meer informatie ? </TH>");
              else {
              out.println("<TH><FONT COLOR='#00008b'>");     
              out.println(meta.getColumnName(j)+" ");
              out.println("</TH>");
              // Hier wordt de tag voor een nieuwe rij afgesloten
              out.println("</TR>");
              // Hier initialiseren we een Integer en String die later zullen worden gebruikt
              int k = 0;
              String nummer ="";
    // Dit deel van de programma code gaan we uitvoeren zolang er nog een volgende rij in de database bestaat
    while (rs.next()) {
              // Voor elke nieuwe rij wordt k verhoogd met 1
              k =k +1;
              // De tag voor een nieuwe rij
              out.println("<TR>");
         // Dit deel van de code wordt uitgevoerd zolang Integer i kleiner is dan het aantal kolommen
         for(int i=1;i <= kolom;i++) {
              // Een nieuwe cel waarin de data worden afgebeeld in de kleur #00008b
              out.println("<TD ALIGN='left' VALIGN ='top'>");
              out.println("<FONT COLOR='#00008b'> ");
              /** Hier halen we de kolomnaam op van kolom i en slagen we deze op in de String kolomnaam. Dan gaan we van           * deze naam de overtollige spaties (links en rechts van de naam) wegwerken.
              String kolomnaam = meta.getColumnName(i);
              kolomnaam = kolomnaam.trim();
              /** Als de kolomnaam gelijk is aan "project" dan gaan we de data van deze cel opslagen in de String nummer en           * deze dan doorsturen naar de client. Anders gaan we voort in onze programma code.
              if (kolomnaam.equals("project")) {
              nummer = rs.getString(i);
              out.println(nummer);
              /** Als het vorige niet waar is dan gaan we zien of de kolomnaam gelijk is aan "informatie", als dat zo is           * dan gaan we de data van de cel opslaan in de String celwaarde.
              else if ( kolomnaam.equals("informatie")) {
                   String celwaarde = rs.getString(i);
                   char punt = '.';
                   char under ='_';
                   nummer = nummer.replace(punt,under);               
                   /** Als deze String celwaade gelijk is aan "Y" dan gaan we een hyperlink afbeelden die opgebouwd is                * uit drie delen : de naam "project", de String nummer (de data uit de cel van project waar het                * "." is vervangen door "_" ) en de extensie ".html"
                   if (celwaarde.equals("Y") ){
                   out.println("<A HREF=project" + nummer + ".html> Project" +" "+ k +" </A>");     
                   /** Als de celwaarde niet gelijk is aan "Y" dan gaan we gewoon de naam "Project" en de Integer k                * afbeelden
                   else {
                   out.println("Project" +" " + k);
              else {
              out.println(rs.getString(i));
              out.println("</FONT>");
              out.println("</TD>");
              out.println("</TR>");
         out.println(" </TABLE>");
         out.println("</BODY>");
         out.println("</HTML>");
         // Hier wordt het object Satement afgesloten vermts we het niet meer nodig hebben
         stm.close();
    // Als er bij het uitvoeren van de programma code een fout zich voordoet dan wordt er een foutmelding weergegeven
    catch (SQLException e) {
    System.out.println(e.toString());

    The exception is thrown in the Doget method namely stm = con.createStatement();
    But i think that when i run my servlet that the init method is not used. I believe the problem is the access to the database.
    Thanks for the answer because i'm beginning to hate the cobalt server at my school

  • Using blobs with SQL*Net 8

    Hello,
    Can someone please help me get oriented in the following:
    Clients have Oracle Forms Developer 6i installed on 100 machines. This is from 1996 I think. It comes with SQL*Net 8.
    They want a simple utility that uploads a file into a blob field on the remote database.
    I already developed the utility thinking that they have Oracle 9i2 installed - so I used OCCI. This is not a possibility with the old technology they are actually using..
    So what is the place to start?
    Thank you!!
    david

    You can try with PRO-C

  • How to use Ago function in BIEE with mysql database

    Hi experts,
    Ago function works well in Oracle database,but when I tried a mysql database,it didn't show results as expected. Anyone knows how to use Ago with mysql as data source?

    Hi Gurus, need help

  • Using BC4J with MS Access/MySQL

    Hi,
    I have to develop a small application for PC consisting of somes input forms and a data report (for screen & printer). I'm new to the BC4J framework and I don't have any experiencie with it.
    I will work with one of this DB: MS Access or MySQL (SQL 92 compliant).
    Before beginning my work I would want to know if somebody has any experience on using the framework with one of these databases. If so, does the framework work well with these databases? Is there some known problem or limitation? Has anybody some remendation on this matter?
    Thank you so much.
    M Laura.

    Although we don't formally test with MySQL,
    we have an inhouse project that uses
    BC4J with MySQL - it works well.
    The only way into Access is via the JDBC:ODBC bridge,
    which I've always found troublesome.
    regards, Karl McHorton (bc4j development)

  • Can datamodeler be used with MySQL?

    Is it possible to use this product with MySQL databases? If so, is there a reference on how to do that?

    Hello Ray,
    Appreciate the problem you have, the link with DFD to the tables is not clear. The issue is that DFDs are really meant to be Logical rather than Physical, though I can see no reason for the functionality not to be available in the Physical environment too.
    I have answered this query several times, it seems to be a fairly common question, have a look at the following thread, will save me having to write it up all again:
    SQL DM - Data Transformation and Data Movement option ?
    If you are going to use this with MySQL then perhaps the Oracle support can advise on how to load the relevant MySQL libraries that will generate the correct MySQL DDL, would be good if everything could be standardised to one tool and I no longer need to use MySQL Workbench.
    Kind regards,
    Yusef

  • Date Problem in Java with MySql

    Hello
    I am using Java with Mysql.I want to enter date in some in my format(YYYY:MM:DD:HH:MM:SS), this thing i have convert using format class and format class return date in String and iwwnat to insert this value in MySQL Table,So i want to know how can i convert String value in Date for Mysql is their inbuild function for converting string into date in mysql.
    Regards
    Anupam S

    Use PreparedStatement and SimpleDateFormat classes
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=%2BPreparedStatement+%2BSimpleDateFormat+&qp=siteforumid%3Ajava48&chooseCat=allJava&col=developer-forums&site=dev

  • Php4 with mysql

    I need to get this to work..... php4.3.10 with mysql...
    tried about every single PKGbuild i could find, but every single one
    of them dont give me support for mysql... Meaning trying to use phpmyadmin i get mysql module not loaded ... I have used this pkgbuild in which you can see i do use the --with mysql flag/option... can some one plz help me out here or tell me where i go wrong or what i have to do to make it work ???? plz ....
    pkgname=php
    pkgver=4.3.10
    pkgrel=2
    pkgdesc="A high-level scripting language"
    backup=(etc/php.ini)
    depends=('openssl' 'libjpeg' 'freetype2' 'libpng' 'pam' 
             'gdbm' 'libxslt' 'openldap')
    makedepends=('apache' 'mysql' 'bzip2' 'smtp-server')
    source=(http://www.php.net/distributions/$pkgname-$pkgver.tar.gz php.ini)
    url="http://www.php.net"
    build() {
      cd $startdir/src/$pkgname-$pkgver
      ./configure --with-apxs2 --prefix=/usr --sysconfdir=/etc 
        --with-ttf --enable-mailparse --with-config-file-scan-dir=/etc 
        --enable-bcmath=shared --enable-calendar=shared --enable-ftp=shared 
        --enable-gd-native-ttf --enable-magic-quotes --enable-posix=shared 
        --enable-session --enable-shared --enable-shmop=shared 
        --enable-sysvsem=shared --enable-sysvshm=shared --enable-track-vars 
        --enable-trans-sid --enable-safe-mode --enable-sockets=shared 
        --enable-xml --with-bz2=shared --without-db2 --without-db3 
        --with-freetype-dir=/usr --with-gd --with-gdbm --enable-exif 
        --with-jpeg-dir=/usr --with-mysql=shared,/usr --with-ldap 
        --with-mysql-sock=/tmp/mysql.sock --with-openssl --with-gettext 
        --with-pear=/usr/share/pear --with-dom --with-dom-xslt 
        --with-png-dir=/usr --with-regex=php --with-zlib --with-curl
      make || return 1
      mkdir -p $startdir/pkg/usr/lib/apache
    #  cp config_vars.mk config_vars.old
    #  sed "s|^INSTALL_IT.*$|INSTALL_IT = apxs -i -a -S LIBEXECDIR=$startdir/pkg/usr/lib/apache -n php4 libs/libphp4.so|" config_vars.old >config_vars.mk
      sed -i "s|-i -a -n php4|-i -n php4|g" Makefile
      make INSTALL_ROOT=$startdir/pkg EXTENSION_DIR=/usr/lib/php install
      cp ../php.ini $startdir/pkg/etc

    exactly. build php. install the package.
    find out what the name of the mysql extension is..
    ls -lR /usr/lib/php/extensions | grep -i 'sql'
    look for the one that is similar to mysql.so or something..
    then edit php.ini, and add
    extension=mysql.so
    if might already be in there...just uncomment it if it is.
    then restart apache.

  • Hibernate problems with Mysql

    Hi, we are using Hibernate with MySQL and c3p0 in our Struts Web application. Hibernate appers to give us errors in a random fashion when we're accesing our web pages. usually after 1 reload everything works fine
    any idea on what could be wrong?
    javax.servlet.ServletException: could not execute query
         org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
         org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    org.hibernate.exception.JDBCConnectionException: could not execute query
         org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
         org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
         org.hibernate.loader.Loader.doList(Loader.java:2148)
         org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
         org.hibernate.loader.Loader.list(Loader.java:2024)
         org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
         org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
         org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
         org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
         org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
         cz.roster.business.destinations.hotels.DestinationsHotelsListRead.perform(DestinationsHotelsListRead.java:22)
         cz.roster.actions.destinations.hotels.HotelsListAction.execute(HotelsListAction.java:41)
         org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Message was edited by:
    snoopy_cz

    Huh? DAOs abstract your data access layer away from the specific underlying implementation.
    Unless you fancy writing an HQL implementation that can liaise with flat files (or whatever you're swapping it for) there's no way you can just swap Hibernate out for something else otherwise.
    Whereas if you put Hibernate behind a decent set of DAOs you can easily do this. So they don't have much in common. It's true that you can generate DAOs using Hibernate, but that's (a) not the same thing and (b) not a great idea.

  • ACS with MySQL

    Hi, Is it possible to use ACS with mySQL database?
    regards
    Steffen

    Depends on what you mean.
    The ODBC Authenticator (that is authenticate users against an external ODBC datasource) should work fine with mySQL. There is a white paper I wrote still kicking about on CCO somewhere if you search for it.
    If you mean can you use mySQL for ACSs own internal database.. then no you cant.
    Darran

  • Connection pooling with mysql!!

    Hi,
    I've been reading about connection pooling for days. I want to use it with mysql. I believe that the vendor usually supplies implementations for the javax.sql.PooledConnection and javax.sql.ConnectionPoolDataSource, but I can't find this on the mysql site or any forums.
    PoolMan from www.codestudio.com was suggested but that doesn't seem to exist anymore.
    I really don't want to build my own from scratch. Does anyone have any suggestions????
    Thanks in advance,
    Louise.

    >
    PoolMan from www.codestudio.com was suggested but that
    doesn't seem to exist anymore.
    What about this
    http://sourceforge.net/projects/poolman

  • How to use CMP in Weblogic 9.2 with MySQL?

    Hello all...
    So I've been tasked wiith moving an Oracle/Weblogic installation to a MySQL/Weblogic platform. Things are moving along well, except that in my CMP (Container-Managed Persistence) descriptors, the database-type is set to "Oracle" and there are references to columns of type "OracleBlob" and "OracleClob".
    I changed database-type to "MySQL" and those columns to "Blob" and "Clob", but it doesn't work -- Weblogic reports that MySQL doesn't support Blobs and Clobs (which is untrue, but perhaps Weblogic 9.2 doesn't know how to deal with MySQL Blobs and Clobs).
    Has anyone encountered this before? Is there a workaround? I've Google'd it and looked here, and it doesn't seem like many people use this combination of MySQL and Weblogic, so there's not much discussed on this topic.
    Any help would be much appreciated!
    - Tim Bessie

    First you need to make sure that you are using supported configuration. CMP (WebLogic feature) is supported with MySql4 with Connect/J
    http://edocs.bea.com/platform/suppconfigs/configs92/92_over/supported_db.html#1177621
    Thanks,
    Jayesh
    Yagna Sys

Maybe you are looking for