struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ch...@chrismiles.org
Subject Re: PersistenceFacade
Date Wed, 26 May 2010 13:39:54 GMT
Hi,

You would need to post your strack trace and where the problem happens.

Chris

> Hi.
>
>
>
> I have used the following code with struts 1.2x and it works just fine.
> Now
> I have upgraded to Struts 1.3.10.
>
>
>
> Now I get the following error when I try to login to my Struts app.
>
>
>
> Can anybody point me in the right direction.
>
>
>
> Soren, DK
>
>
>
> The Code:
>
>
>
> package nc.persistence;
>
>
>
> import java.sql.Connection;
>
> import java.sql.SQLException;
>
> import javax.servlet.http.HttpServlet;
>
> import java.sql.DriverManager;
>
>
>
> public class PersistenceFacade {
>
>
>
>   //----------- fields ---------//
>
>
>
>                       public static final String CONNECTION_DRIVER =
> "org.gjt.mm.mysql.Driver";
>
>                       public static final String CONNECTION_USER   =
> "username";
>
>                       public static final String CONNECTION_PASS   =
> "password";
>
>                       public static final String CONNECTION_URL    =
> "url";
>
>
>
>                       static {
>
>     try {
>
>       Class.forName(CONNECTION_DRIVER);
>
>     } catch (ClassNotFoundException ex) {
>
>
> ex.printStackTrace();
>
>     }
>
>                       }
>
>
>
>                       private String connectionUrl  = null;
>
>                       private String connectionUser = null;
>
>                       private String connectionPass = null;
>
>
>
>
>
>
>
>                       //------------ constructors -----------//
>
>
>
>                       //public PersistenceFacade() {}
>
>
>
>                       public PersistenceFacade(HttpServlet servlet) {
>
>                                             connectionUser =
> servlet.getInitParameter(CONNECTION_USER);
>
>                                             connectionPass =
> servlet.getInitParameter(CONNECTION_PASS);
>
>                                             connectionUrl  =
> servlet.getInitParameter(CONNECTION_URL);
>
>                       }
>
>
>
>                       //------------- public methods -----------//
>
>
>
>                       public Connection getConnection() throws
> SQLException
> {
>
>                                             if(connectionUser == null) {
>
>                                                                  throw new
> SQLException("Missing parameter "+CONNECTION_USER);
>
>                                             } else if(connectionPass ==
> null) {
>
>                                                                  throw new
> SQLException("Missing parameter "+CONNECTION_PASS);
>
>                                             } else if(connectionUrl ==
> null)
> {
>
>                                                                  throw new
> SQLException("Missing parameter "+CONNECTION_URL);
>
>                                             }
>
>                                             return
> DriverManager.getConnection(
>
>
> connectionUrl,
>
>
> connectionUser,
>
>
> connectionPass
>
>                                             );
>
>                       }
>
>
>
>                       public void closeConnection(Connection conn) {
>
>     try {
>
>       if(!conn.isClosed()) {
>
>         conn.close();
>
>       }
>
>     } catch (SQLException ex) {
>
>
> ex.printStackTrace();
>
>     }
>
>                       }
>
>
>
>                       //------------ private methods ----------//
>
> }
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message