On Friday, September 6, 2013 9:49:35 AM UTC+5:30, siva kumar wrote:
HiWhile i am deploying war file and test the application with intranet i got this kind of error ..my application is not working on that time....but in my localhostits working fine...can you give me any solution..............com.mysql.jdbc.exceptions.jdbc4. MySQLNonTransientConnectionExc eption: No operations allowed after connection closed. at sun.reflect.NativeConstructorAccessorImpl. newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl. newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorI mpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java: 411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError. java:1013) at com.mysql.jdbc.SQLError.createSQLException(SQLError. java:987) at com.mysql.jdbc.SQLError.createSQLException(SQLError. java:982) at com.mysql.jdbc.SQLError.createSQLException(SQLError. java:927) at com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException (ConnectionImpl.java:1205) at com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl. java:1197) at com.mysql.jdbc.ConnectionImpl.prepareStatement( ConnectionImpl.java:4186) at com.mysql.jdbc.ConnectionImpl.prepareStatement( ConnectionImpl.java:4152) at data.DataBase.Write(DataBase.java:164) at com.hellomvp.data.dao.PageAccessDAO. accessPagesInsert( PageAccessDAO.java:41) at com.hellomvp.data.bo.useraccountBO.Saveuseraccount( useraccountBO.java:82) at com.hellomvp.server.useraccountserviceImpl. saveuseraccount( useraccountserviceImpl.java: 28) at sun.reflect.NativeMethodAccessorImpl. invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl. invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl. invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.user.server.rpc.RPC. invokeAndEncodeResponse(RPC. java:561) at com.google.gwt.user.server.rpc.RemoteServiceServlet. processCall( RemoteServiceServlet.java:208) at com.google.gwt.user.server.rpc.RemoteServiceServlet. processPost( RemoteServiceServlet.java:248) at com.google.gwt.user.server.rpc. AbstractRemoteServiceServlet. doPost( AbstractRemoteServiceServlet. java:62) at javax.servlet.http.HttpServlet.service( HttpServlet.java:647) at javax.servlet.http.HttpServlet.service( HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain. internalDoFilter( ApplicationFilterChain.java: 305) at org.apache.catalina.core.ApplicationFilterChain. doFilter( ApplicationFilterChain.java: 210) at org.apache.catalina.core.StandardWrapperValve.invoke( StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke( StandardContextValve.java:123) at org.apache.catalina.authenticator. AuthenticatorBase.invoke( AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke( ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke( AccessLogValve.java:947) at org.apache.catalina.core.StandardEngineValve.invoke( StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service( CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor. process( AbstractHttp11Processor.java: 1009) at org.apache.coyote.AbstractProtocol$ AbstractConnectionHandler. process(AbstractProtocol.java: 589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor. run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run( Unknown Source) at java.lang.Thread.run(Unknown Source)Any help would be appreciated...........Regards,Harsha Infotech
Hi Sir,
i had open and closed the database connection.
i had created the connection class like this can you check and reply
public class DataBase {
private static DataBase _Instance;
public static DataBase Instance(ServletContext context) throws ClassNotFoundException, SQLException {
String DBDriver = context.getInitParameter("DBDriver");
String DBConStr = context.getInitParameter("DBConStr");
String DBUser = context.getInitParameter("DBUser");
String DBPassword = context.getInitParameter("DBPassword");
if (_Instance == null) {
_Instance = new DataBase(DBDriver, DBConStr, DBUser, DBPassword);
}
//
return _Instance;
}
public static DataBase Instance(String pDriver, String pConStr, String pUser, String pPassword) throws ClassNotFoundException, SQLException {
if (_Instance == null) {
_Instance = new DataBase(pDriver, pConStr, pUser, pPassword);
}
//
return _Instance;
}
public static DataBase Instance() throws Exception {
if (_Instance == null) {
throw new Exception("Please Use Another Instance Method");
}
//
return _Instance;
}
private class Link {
public Connection DBConnection = null;
public boolean IsInTransaction = false;
public Link(Connection pDBConnection, boolean pIsInTransaction) {
this.DBConnection = pDBConnection;
this.IsInTransaction = pIsInTransaction;
}
}
private String Driver = "com.mysql.jdbc.Driver";
private String ConStr = "jdbc:mysql://localhost:3306/test";
private String User = "";
private String Password = "";
private Link DBLink = null;
private DataBase(String pDriver, String pConStr, String pUser, String pPassword) throws ClassNotFoundException, SQLException {
this.Configure(pDriver, pConStr, pUser, pPassword);
//this.PoolList.add(new Pool(this.Open(), false));
}
public void Configure(String pDriver, String pConStr, String pUser, String pPassword) throws ClassNotFoundException, SQLException {
this.Driver = pDriver;
this.ConStr = pConStr;
this.User = pUser;
this.Password = pPassword;
// if(this.DBLink != null && this.DBLink.DBConnection != null)
// {
// if(this.DBLink.IsInTransaction)
// this.DBLink.DBConnection.rollback();
// this.DBLink.DBConnection.close();
// //
// this.DBLink.DBConnection = null;
// this.DBLink.DBConnection = Open();
// //
// if(this.DBLink.IsInTransaction)
// this.DBLink.DBConnection.setAutoCommit(false);
// }
}
private Connection Open() throws ClassNotFoundException, SQLException {
Class.forName(this.Driver);
Connection oDBConnection = DriverManager.getConnection(this.ConStr, this.User, this.Password);
return oDBConnection;
}
private void Close(Connection oDBConnection) throws ClassNotFoundException, SQLException {
oDBConnection.close();
}
public void BeginTran() throws ClassNotFoundException, SQLException {
if (this.DBLink == null) {
this.DBLink = new Link(this.Open(), true);
}
else if (this.DBLink.DBConnection == null) {
this.DBLink = new Link(this.Open(), true);
}
//
this.DBLink.DBConnection.setAutoCommit(false);
}
public void CommitTran() throws SQLException, ClassNotFoundException {
this.DBLink.DBConnection.commit();
this.Close(this.DBLink.DBConnection);
this.DBLink.DBConnection = null;
this.DBLink.IsInTransaction = false;
}
public void RollbackTran() throws SQLException, ClassNotFoundException {
this.DBLink.DBConnection.rollback();
this.Close(this.DBLink.DBConnection);
this.DBLink.DBConnection = null;
this.DBLink.IsInTransaction = false;
}
private void SetParameter(PreparedStatement pStatement, Integer pIndex, Object pParam) throws SQLException {
if (pParam instanceof Long) {
pStatement.setLong(pIndex, ((Long) pParam).longValue());
} else if (pParam instanceof Integer) {
pStatement.setInt(pIndex, ((Integer) pParam).intValue());
} else if (pParam instanceof Float) {
pStatement.setFloat(pIndex, ((Float) pParam).floatValue());
} else if (pParam instanceof Double) {
pStatement.setDouble(pIndex, ((Double) pParam).doubleValue());
} else if (pParam instanceof Boolean) {
pStatement.setBoolean(pIndex, ((Boolean) pParam).booleanValue());
} else if (pParam instanceof java.sql.Timestamp) {
pStatement.setTimestamp(pIndex, ((Timestamp) pParam));
} else if (pParam instanceof java.lang.String) {
pStatement.setString(pIndex,((String) pParam));
}
}
private void PrepareParams(PreparedStatement stmt, Object[] pParams) throws SQLException {
int i = 1;
for (Object Param : pParams) {
this.SetParameter(stmt, i, Param);
i++;
}
System.out.println("PrepareParams " + stmt.toString());
}
public void Write(String pSQL, Object[] pParams) throws SQLException, ClassNotFoundException {
PreparedStatement stmt = this.DBLink.DBConnection.prepareStatement(pSQL);
PrepareParams(stmt, pParams);
stmt.executeUpdate();
stmt.close();
}
private PreparedStatement StartQuery(String pSQL, Object[] pParams) throws SQLException, ClassNotFoundException {
if (this.DBLink == null) {
this.DBLink = new Link(this.Open(), false);
} else if (this.DBLink.DBConnection == null) {
this.DBLink = new Link(this.Open(), false);
}
PreparedStatement stmt = this.DBLink.DBConnection.prepareStatement(pSQL);
PrepareParams(stmt, pParams);
return stmt;
}
private void EndQuery(PreparedStatement stmt) throws SQLException, ClassNotFoundException {
stmt.close();
if (!this.DBLink.IsInTransaction) {
this.Close(this.DBLink.DBConnection);
this.DBLink.DBConnection = null;
}
}
public void Read(IBusiness bo, String pSQL, Object[] pParams) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
PreparedStatement stmt = this.StartQuery(pSQL, pParams);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
bo.MapResult(rs);
}
rs.close();
this.EndQuery(stmt);
}
public void ReadRow(IBusiness bo, String pSQL, Object[] pParams) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
//System.out.println("ReadRow::Start" + (bo != null));
PreparedStatement stmt = this.StartQuery(pSQL, pParams);
//System.out.println("ReadRow::After stmt" + (stmt != null));
ResultSet rs = stmt.executeQuery();
//System.out.println("ReadRow::After executeQuery" + (rs != null));
if (rs.next()) {
//System.out.println("ReadRow::Before MapRow");
bo.MapRow(rs);
//System.out.println("ReadRow::After MapRow");
}
rs.close();
//System.out.println("ReadRow::After close resultset");
this.EndQuery(stmt);
//System.out.println("ReadRow::End");
}
public Object ReadSingle(String pSQL, Object[] pParams) throws SQLException, ClassNotFoundException {
PreparedStatement stmt = this.StartQuery(pSQL, pParams);
Object vReturn = null;
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
vReturn = rs.getObject(1);
}
rs.close();
this.EndQuery(stmt);
return vReturn;
}
}
Regards,
Harsha Infotech
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment