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

Similar Messages

  • I want to use hibernate with the tomcat

    I want to use hibernate with the tomcat server can it be possible and if yes then what is the stepwise way.
    Infact I know the java JSF but want to command on Hibernate plz help me.
    I'll be thankful to you.

    To be honest, I wouldn't even know where to start. Do you know what Hibernate does and how it works? Do you know how Tomcat works? All you'd need to do to combine those two would be to let Tomcat provide the DB connections for Hibernate, I suppose. Neither of those products are a topic of this board though.

  • 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

  • IS IT POSSIBLE TO USE HIBERNATE WITH NETBEAN?

    Hi and Happy New year,
    Please, is it possible to use hibernate with netbean. If yes, where can I get the materials on the configuration.
    Thanks
    Emeka

    NetBeans is an IDE. Hibernate is a data access API/solution. So not sure what you're asking. If you want to know if NetBeans IDE has Hibernate integration, go look at NetBeans feature set and/or plugins. Either way, Google...

  • Question about using Logic with guitar on stage. HELP!

    Hello,
    I'm a guitarist.
    I would need some advises about using Logic in a live situation..
    How do you move from one track to the other using the keyboard?
    Could that action be controlled by some kind of footswitch?
    Also, the REC button has to be always ON to hear the sound or is there another way to set that up?
    I would like to create let's say 6 tracks with plugins for having 6 different guitar sounds.
    Is it very heavy for the CPU?
    I'm using a macbook with 2GB of ram and a firewire FA-66 edirol sound card.
    Would you also recommend to use a preamp?
    Many many thanks for your help!
    Ciao
    Chester
    MacBook, Powerbook 17", iPod 4G, LaCie HD   Mac OS X (10.4.8)  

    Why to jump from one track to another?
    Simply create a folder with all the Channel strip settings and assign two key commands of your choice to navigate forward and backward.
    And yes, you can assign that command to a MIDI controller (or pedal) too.
    About monitoring have a look at the reference manual page 211.
    Before to buy a preamp try using the Hi-Z input from your Edirol.
    Anyway, six tracks with six plugins on each track are not an issue for your macbook.
    cheers
    rob
    Power Mac G4/533 PowerBook 12   Mac OS X (10.4.8)  

  • Need Info about using Strut with WL 7.0

    I want to find out how to use it with WL 7.0. Would anyone give me any info about it? :) Thanks
              

    You could download and deploy "struts-example.war" from apache website.
              [That Struts 1.0.2 I think.]
              ---Nam
              Jordy wrote:
              > I want to find out how to use it with WL 7.0. Would anyone give me any info about it? :) Thanks
              And God said
              Let there be numbers
              And there were numbers.
              Odd and even created he them,
              He said to them be fruitful and multiply,
              And he commanded them to keep the laws of induction.
              [Bill Taylor [email protected]]
              [nam_nguyen.vcf]
              

  • Using Hibernate with WAS

    Hi,
    I've been trying to port an application from Apache to Netweaver WAS. We use Hibernate. I'm getting a null pointer in reference to the Hibernate session. It seems that Hibernate is not loading properly. I'm wondering if it has to do with the location of the cfg.xml files. They were under WEB/INF (which is where Apache wants them) but I've tried putting them under /Classes and that doesn't work either. Any help or ideas appreciated.
    thanks,
    LG

    I've been using Hibernate on SAP Web AS as well.
    I put the hibernate.cfg.xml file under WEB-INF/classes and the ***.hbm.xml files in the /source at the same location as the corresponding java class.

  • 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

  • Is there a detailed tutorial about using Subversion with JDeveloper?

    Hi,
    My project is currently in my single-user repository, and I have checked out, modified, and checked in my files. All that works fine, but there is much more functionality available. At the moment, I am going through some YouTube videos by Stuart Fleming, but I was hoping that someone might suggest an article that I could keep as a searchable reference.
    Thanks.
    James

    Hi Timo,
    Using Subversion with JDeveloper is the only way I use it. Would you explain what you mean below?
    You just need a couple of method which are not dependant on jdev.
    Thanks.
    James

  • Error in using Hibernate with EJB

    I have generated my Hibernate related configurtion file,POJO Classes & hbm files using MyEclipse 5.0. And Iam using JBuilder 10.0.176.0
    to develop the EJB module. When i try to compile my module it is saying POJO class is bad.
    "Bean2InsertBean.java": cannot access ejb_hibernate.Testsql,bad class file: D:\MyJava\bea\OurClasses\ejb_hibernate\Testsql.class,class file has wrong version 49.0, should be 48.0,Please remove or make sure it appears in the correct subdirectory of the classpath.
    But the classes are in correct directory.

    It looks like you have compiled the POJO class with Java 5 version whereas you are compiling the EJB module with Java1.x (i.e. a lower version). Compile the POJO class with Java 1.x and then try compiling the EJB module with the same version

  • Question about using RE1000 with EA6500

    I have an EA6500 route but having problem getting wireless signal to one room in my house.  As a result, I am thinking about buying RE1000.
    If I buy this unit, will I need to connect to a different network when using wireless devices in the room near the extender.
    Or will both the extender and router operate as a single wireless network name?  If they both operate under a single wireless name, how will I know the extender is connecting and working.
    Please let me know.  Thanks.

    atomarchio wrote:
    I have an EA6500 route but having problem getting wireless signal to one room in my house.  As a result, I am thinking about buying RE1000.
    If I buy this unit, will I need to connect to a different network when using wireless devices in the room near the extender.
    Or will both the extender and router operate as a single wireless network name?  If they both operate under a single wireless name, how will I know the extender is connecting and working.
    Please let me know.  Thanks.
    Just to answer your question, RE1000 will extend your router's main wireless network - so they will operate with single / same wireless network name. You'll know that the extender is connected and working if you'll be able to see the RE1000 listed on your router's DHCP client's table.
    If everyone needs to believe in something, I believe I'll have another beer..

  • Helo about using passwordfield with database

    im new to passwordfield stuff because i use textfield and i can use it very well
    my error is
    setString(int,java.lang.String) in java.sql.PreparedStatement cannot be applied to (int,char[])
    and the second error
    symbol : method equals(char[],java.lang.String)
    location: class java.util.Arrays
    if(uname.equals(result.getString(1)) && Arrays.equals(pass,result.getString(2)))
    here is my code
    String uname = txtusername.getText();
          char pass[] = txtpassword.getPassword(); // <--- see i use passwordfield and it has a method getpassword()
         if(uname.length() < 1 || pass.length < 1)
         JOptionPane.showMessageDialog(null, "Please enter your username and password");
         else
            try
                Class.forName(driver);
            }//end try
            catch(Exception e)
               JOptionPane.showMessageDialog(null, "Failed to load MySql driver!");
               return;
            }//end catch
            try
                con = mydb.getmyconnection();
                String statement = "Select * from login where username = ? and password = ?";
                PreparedStatement preparedst = mydb.getmyconnection().prepareStatement(statement);
                preparedst.setString(1, txtusername.getText());
                preparedst.setString(2, txtpassword.getPassword()); // <---here i have an error too if i use getpassword but if i use gettext its fine
                ResultSet result = preparedst.executeQuery();
                while(result.next())
                 if(uname.equals(result.getString(1)) && Arrays.equals(pass,result.getString(2)))
                    JOptionPane.showMessageDialog(null, "Login Successful!");
                    inserttable.main(null);
                    this.dispose();
                  else
                      JOptionPane.showMessageDialog(null, "invalid login");
                preparedst.close();
                con.close();
               catch(SQLException e)
                JOptionPane.showMessageDialog(null, e.getMessage());
         }//end else
    }                 but if i use gettext instead of getpassword and i change my code with this it works fine
    String uname = txtusername.getText();
          String pass = txtpassword.getText();
         if(txtusername.getText().length() < 1 || txtpassword.getText().length() < 1)
         JOptionPane.showMessageDialog(null, "Please enter your username and password");
         else
            try
                Class.forName(driver);
            }//end try
            catch(Exception e)
               JOptionPane.showMessageDialog(null, "Failed to load MySql driver!");
               return;
            }//end catch
            try
                con = mydb.getmyconnection();
                String statement = "Select * from login where username = ? and password = ?";
                PreparedStatement preparedst = mydb.getmyconnection().prepareStatement(statement);
                preparedst.setString(1, txtusername.getText());
                preparedst.setString(2, txtpassword.getText());
                ResultSet result = preparedst.executeQuery();
                while(result.next())
                  if(uname.equals(result.getString(1)) && pass.equals(result.getString(2)))
                    JOptionPane.showMessageDialog(null, "Login Successful!");
                    inserttable.main(null);
                    this.dispose();
                  else
                      JOptionPane.showMessageDialog(null, "invalid login");
                preparedst.close();
                con.close();
               catch(SQLException e)
                JOptionPane.showMessageDialog(null, e.getMessage());
         }//end else
    }                Edited by: Jaywhy on Mar 18, 2009 8:38 PM

    i did that already with .equals method but its not working if i use passwordfield if i enter invalid username and password nothing happened
                while(result.next())
                  if(uname.equals(result.getString(1)) && pass.equals(result.getString(2)))
                    JOptionPane.showMessageDialog(null, "Login Successful!");
                    inserttable.main(null);
                    this.dispose();
                  else
                      JOptionPane.showMessageDialog(null, "invalid login");
                  }nvm i change the code and got the idea of you thank's
    Edited by: Jaywhy on Mar 18, 2009 9:39 PM

  • Question about using calendar with Microsoft Exchange

    I just recently bought the iPhone5.  I used to have a Droid so I am new to the iPhone altogether.  I have a 3rd generation iPad as well.  I've always used my google calendar on my droid to set up appointments and whatnot on my calendar and I send the invites to my husband so we can sync our calendars.  He would then accept or decline and I would get an email notification saying when he did so.  Now that I am using the iPad and iPhone calendar, I am super confused.  There are so many color coded calendars.  I set up the Microsoft Exchange account on both mine and my husbands phone and I set the default calendar to the Gmail Exchange calendar as someone told me to do.  I'm very confused by what this is all about and my husband still isn't getting the invitations when I send it to his gmail.  However, when I sent it to his aol email address, he did receive an invite but on my calendar it is still showing as "no response".  Also, now we are getting emails in 2 different gmail inboxes, one for the exchange and one for just gmail.  What's the difference?  Can anyone shed some light on this for me?  I'm such a newbie and googling isn't helping!
    Thanks!!!!

    Why to jump from one track to another?
    Simply create a folder with all the Channel strip settings and assign two key commands of your choice to navigate forward and backward.
    And yes, you can assign that command to a MIDI controller (or pedal) too.
    About monitoring have a look at the reference manual page 211.
    Before to buy a preamp try using the Hi-Z input from your Edirol.
    Anyway, six tracks with six plugins on each track are not an issue for your macbook.
    cheers
    rob
    Power Mac G4/533 PowerBook 12   Mac OS X (10.4.8)  

  • 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)

Maybe you are looking for