Return-Path: Delivered-To: apmail-geronimo-user-archive@www.apache.org Received: (qmail 64297 invoked from network); 7 Jan 2008 18:33:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Jan 2008 18:33:26 -0000 Received: (qmail 12199 invoked by uid 500); 7 Jan 2008 18:33:09 -0000 Delivered-To: apmail-geronimo-user-archive@geronimo.apache.org Received: (qmail 12168 invoked by uid 500); 7 Jan 2008 18:33:09 -0000 Mailing-List: contact user-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: user@geronimo.apache.org List-Id: Delivered-To: mailing list user@geronimo.apache.org Received: (qmail 12152 invoked by uid 99); 7 Jan 2008 18:33:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Jan 2008 10:33:09 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jpmlpool@hotmail.com designates 65.54.246.101 as permitted sender) Received: from [65.54.246.101] (HELO bay0-omc1-s29.bay0.hotmail.com) (65.54.246.101) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Jan 2008 18:32:56 +0000 Received: from hotmail.com ([65.54.168.80]) by bay0-omc1-s29.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 7 Jan 2008 10:32:47 -0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 7 Jan 2008 10:32:47 -0800 Message-ID: Received: from 24.86.123.169 by BAY113-DAV8.phx.gbl with DAV; Mon, 07 Jan 2008 18:32:42 +0000 X-Originating-IP: [24.86.123.169] X-Originating-Email: [jpmlpool@hotmail.com] X-Sender: jpmlpool@hotmail.com From: "jpmlpool" To: References: <14525371.post@talk.nabble.com> <1b5bfeb50712280809i1389dffo481ccd0f9cce994b@mail.gmail.com> <917FAAAE-2CFB-4171-BDC8-45A8DA011255@yahoo.com> <14528043.post@talk.nabble.com> <1b5bfeb50712281123w5175133dr683a3e57a4a719a1@mail.gmail.com> <14580002.post@talk.nabble.com> Subject: Questions about MySql and Geronimo Date: Mon, 7 Jan 2008 10:32:35 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 X-OriginalArrivalTime: 07 Jan 2008 18:32:47.0626 (UTC) FILETIME=[B38C76A0:01C8515B] X-Virus-Checked: Checked by ClamAV on apache.org Hello I am still struggling with Geronimo and MySql. I tried to change the deploy plans following some articles, but I still can not access MySql server from Geronimo. Attached are related files, because I zipped Ear and War projects created on Eclipse, but I cannot send it to this email address. If you know my errors, please help me. At the bottom is my previous email with more details. Environments or what I did (1) Geronimo 2.0.2 (2) Database pool created from Geronimo Admin console Database pool : QiMySql Database : hellodb a database Table : pet (3) Eclipse 3.3.1 with WTP (4) OS : Windows 2000 (5) SqlPetStoreEar and SqiPetStoreWar projects on Eclipse John Qi ============================= ====== SqlPetStoreEar/EarContent/METF-INF/application.xml ====== SqlPetStoreWar.war SqlPetStoreWar ====== SqlPetStoreEar/EarContent/METF-INF/geronimo-application.xml ====== com.sn.web.db.mysql.demo.pet MySqlPetStoreEarId 1.0 ear ====== SqlPetStoreWar/WebContent/WEB-INF/geronimo-web.xml ====== com.sn.web.db.mysql.demo.pet SqlPetStoreWarId 1.0 war /SqlPetStoreWar ====== SqlPetStoreWar/EarContent/WEB-INF/web.xml ====== SqlPetStoreWar index.html index.jsp ListPets ListPets com.sn.web.db.mysql.demo.pet.ListPets ListPets /ListPets ================ ListPets.java =============== protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub this.getPets(request, response); } private void getPets(HttpServletRequest request, HttpServletResponse response) { Statement stmt = null; ResultSet rs = null; try { InitialContext ctx = new InitialContext(); // error : can not find this data source DataSource ds = (DataSource)ctx.lookup("java:comp/env/QiMySql"); // error : this line does not work on Geronimo, but works fine in java application. Class.forName("com.mysql.jdbc.Driver").newInstance(); String url = "jdbc:mysql:///hellodb?user=root&password=hello"; Connection con = DriverManager.getConnection(url); stmt = con.createStatement(); String sql = "SELECT * FROM PET"; rs = stmt.executeQuery(sql); while (rs.next()) { String no = rs.getString("NAME"); String lang = rs.getString("OWNER"); String msg = rs.getString("SEX"); System.out.println(no + " " + lang + " " + msg); } stmt.close(); con.close(); } catch (Exception e) { e.printStackTrace(); } finally { if (rs != null) { try { rs.close(); } catch (SQLException sqlEx) { } } if (stmt != null) { try { stmt.close(); } catch (SQLException sqlEx) { } } rs = null; stmt = null; } } ============================= ----- Original Message ----- From: "jpmlpool" To: Sent: Wednesday, January 02, 2008 9:40 AM Subject: question about MySql and Geronimo > Happy New Year ! > > What I want to do are > (1) when I start Geronimo, MySql server is started automatically by > Geronimo. > (2) I can access MySql, just like now I can access Derby. > (3) if possible, for example, there are two Derbys and two MySqls, I can > access them for different purpose. I do not know if this is possible, > if > possible, HOW TO DO. > > What I did are > (1) downloaded MySql 5.0.54 and installed it. (OK) > (2) from console I can access the MySql. (OK) > > mysql> show tables; > > +-------------------+ > > | Tables_in_hellodb | > > +-------------------+ > > | pet   | > > | wishtable   | > > +-------------------+ > > 2 rows in set (0.00 sec) > > > > mysql> SELECT * FROM pet; > > +----------+-------+---------+------+------------+------------+ > > | name | owner | species | sex | birth | death | > > +----------+-------+---------+------+------------+------------+ > > | Fluffy | | Harold | c | 0000-00-00 | 1993-02-04 | > > | Claws | | Gwen | c | 0000-00-00 | 1994-03-17 | > > | Buffy | | Harold | d | 0000-00-00 | 1989-05-13 | > > | Fang | | Benny | d | 0000-00-00 | 1990-08-27 | > > | Bowser | | Diane | d | 0000-00-00 | 1979-08-31 | > > | Chirpy | | Gwen | b | 0000-00-00 | 1998-09-11 | > > | Whistler | Gwen | bird | | 1997-12-09 | NULL | > > | Slim | | Benny | s | 0000-00-00 | 1996-04-29 | > > +----------+-------+---------+------+------------+------------+ > > 8 rows in set (0.00 sec) > > > > (3) downloaded the MySql driver mysql-connector-java-3.1.12.jar > > through Geronimo's console. > > the driver is placed in repository\mysql\mysql-connector-java\3.1.12 > > > > (4) From Eclipse I created a Java Application, and I can > > access the MySql using Java code below. The results are correct. > > > > Class.forName("com.mysql.jdbc.Driver").newInstance(); > > String url = "jdbc:mysql:///hellodb?user=abc&password=xyz"; > Connection con = DriverManager.getConnection(url); > > > > (5) I created a Dynamic web project and a servlet, and used the > > same code in the servlet as above, but I got next error message. > > > > java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in classloader > com.sn.web.db.mysql.demo.pet/SqlDemoPetStoreId/1.0/war > at > org.apache.geronimo.kernel.config.MultiParentClassLoader.loadOptimizedClass( > MultiParentClassLoader.java:428) > at > org.apache.geronimo.kernel.config.MultiParentClassLoader.loadClass(MultiPare > ntClassLoader.java:278) > at java.lang.ClassLoader.loadClass(Unknown Source) > at java.lang.ClassLoader.loadClassInternal(Unknown Source) > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Unknown Source) > at com.sn.web.db.mysql.demo.pet.ListPets.getPets(ListPets.java:82) > at com.sn.web.db.mysql.demo.pet.ListPets.doGet(ListPets.java:43) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:693) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) > > ..... > > > > Do you have any ideas ? > > > > Thanks in advance. > > > > John Qi > > > > > > > >