tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mihamina Rakotomandimby (R12y)" <miham...@lab.vectoris.fr>
Subject Re: tomcat only query localhost database
Date Tue, 03 Feb 2009 13:46:29 GMT
Gregor Schneider wrote:
> Sorry, but you're providing too few informations.
> 
> - please post the file /etc/tomcat6/Catalina/localhost/webappName.xml
> (masquerade the user-id / password!)

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/norpassWeb"
                 reloadable="true"
                 docBase="norpassWeb" >

         <Resource name="jdbc/norpassDBPool"
                   auth="Container"
                   type="javax.sql.DataSource"
                   maxActive="100"
                   maxIdle="100"
                   maxWait="30000"
                   removeAbandoned="true"
                   removeAbandonedTimeout="20"
                   logAbandoned="true"
                   autoCommit="true"
                   username="xxxxxxxx"
                   password="yyyyyyyy"
                   driverClassName="org.gjt.mm.mysql.Driver"
         url="jdbc:mysql://77.88.777.999:3306/dbname?autoReconnect=true"
/>
</Context>


> - please post the piece of code where the said webapp tries to create
> the database-connection.

(A more readable version is attached)

public static Connection getConnection() throws SQLException
{
     try {
         if (null == s_dataSource)
             {
                 try
                     {
                         Context envCtx = (Context) new InitialContext();
                         if(envCtx == null )
                             throw new Exception("ERROR - No Context");
                         s_dataSource = (DataSource) 
envCtx.lookup("java:comp/env/jdbc/norpassDBPool");
                     }
                 catch (NamingException e)
                     {
                         e.printStackTrace();
                         throw e;
                     }
             }
         return s_dataSource.getConnection();
     }
     catch(Exception e)
         {
             try
                 {
                     Class.forName("org.gjt.mm.mysql.Driver");
                 }
             catch (ClassNotFoundException e1)
                 {
                     e1.printStackTrace();
                 }

             Connection con =
 
DriverManager.getConnection("jdbc:mysql://localhost/baseName",
                                             "login",
                                             "password");
             con.setAutoCommit(false);
             return con;
         }
}

-- 
Chef de projet chez Vectoris
http://www.google.com/search?q=mihamina+rakotomandimby

Mime
View raw message