
Hi everyone
i would like to ask few question here,since i try to configure this out for 1 week,i dont find any solution for my problem. T_T I have develop my java web application in window Environment and now i have buy domain and hosting(linux) where i put my web system there.I deploy the project in WAR file and then i upload to my hosting. The problem come when my system won't be able to connect to database in pooling environment. i try follow some tutorial how to solve it.But thing still remain the same. In my laptop,everything work very well but thing doesnt go well in the real hosting. My humble request if any of you have any idea how to solve it?
here my code for connection:
file name:context.xml
<Context path="/Mysystem"> <Resource name="jdbc/database_name" auth="Container" maxActive="100" maxIdle="30" maxWait="10000" username="username" password="password" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/database_name?autoReconnect=true" logAbandoned="true" removeAbandoned="true" removeAbandonedTimeout="60" type="javax.sql.DataSource" /> </Context>
[Post New]posted Today 5:04:40 PM Quote Edit Hi everyone
i would like to ask few question here,since i try to configure this out for 1 week,i dont find any solution for my problem. T_T I have develop my java web application in window Environment and now i have buy domain and hosting(linux) where i put my web system there.I deploy the project in WAR file and then i upload to my hosting. The problem come when my system won't be able to connect to database in pooling environment. i try follow some tutorial how to solve it.But thing still remain the same. In my laptop,everything work very well but thing doesnt go well in the real hosting. My humble request if any of you have any idea how to solve it?
here my code for connection:
file name:context.xml view plaincopy to clipboardprint?
<Context path="/Mysystem"> <Resource name="jdbc/database_name" auth="Container" maxActive="100" maxIdle="30" maxWait="10000" username="username" password="password" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/database_name?autoReconnect=true" logAbandoned="true" removeAbandoned="true" removeAbandonedTimeout="60" type="javax.sql.DataSource" /> </Context>
and i have create connection pooling class..here the code
filename: ConnectionPool.java
public class ConnectionPool
{
private static ConnectionPool pool = null;
private static DataSource dataSource = null;
private ConnectionPool()
{
try
{
InitialContext ic = new InitialContext();
dataSource = (DataSource) ic.lookup("java:/comp/env/jdbc/database_name");
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static ConnectionPool getInstance()
{
if (pool == null)
{
pool = new ConnectionPool();
}
return pool;
}
public Connection getConnection()
{
try
{
return dataSource.getConnection();
}
catch (SQLException sqle)
{
sqle.printStackTrace();
return null;
}
}
public void freeConnection(Connection c)
{
try
{
c.close();
}
catch (SQLException sqle)
{
sqle.printStackTrace();
}
}
}
so what error is occur,i paste it here:
java.lang.NullPointerException data.ConnectionPool.getConnection(ConnectionPool.java:38) data.UserDB.checkStoreOfficer(UserDB.java:45) registration.CheckUser.doPost(CheckUser.java:43) javax.servlet.http.HttpServlet.service(HttpServlet.java:647) javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
for your information,in my hosting..i'm using tomcat version 5.5.x
Thanks for your concern for spend your time at my question here.I really appreciate it.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.