Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database

Ads
 

Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database

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.

View Answers

Ads









Related Tutorials/Questions & Answers:
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Null pointer exceptation-Java Servlet web application,Problem connecting.... T_T I have develop my java web application in window Environment and now i.... T_T I have develop my java web application in window Environment and now i
Connecting to MYSQL Database in Java
Connecting to MYSQL Database in Java  I've tried executing the code...("MySQL Connect Example."); Connection conn = null; String url... please help here coz I have tried to locate the problem but I can't find
Advertisements
null pointer
null pointer  dear sir , what is mean by null pointer in c
null pointer exception in java
null pointer exception in java  What is null pointer exception in Java and when it occurs? Show it with an example.Thanks!   Java Null Pointer Exception
Null pointer execption
Null pointer execption  what is null pointer exception. I am getting the null pointer exception in this line conn= com.mypay.dao.Connection.getConnection(); what is wrong
Null pointer execption
Null pointer execption  what is null pointer exception. I am getting the null pointer exception in this line conn= com.mypay.dao.Connection.getConnection(); what is wrong
Httpservletresponse null pointer exception.
Httpservletresponse null pointer exception.  What is Httpservletresponse null pointer exception?   NullPointerException occurs when we try to implement an application without referencing the object and allocating
NUll POINTER EXCEPTION
NUll POINTER EXCEPTION  public void doGet(HttpServletRequest request... of code i m getting null pointer Exception. can some one please explain what is the problem in this block of code....  1)grosspay.jsp: <html> <
Null Pointer Exception
Null Pointer Exception  whis is the Null Pointer Exception in java? or define Null Pointer Exception with exp?   NullPointerException occurs, when you try to implement an application without referencing the object
NULL POINTER EXCEPTION
NULL POINTER EXCEPTION    What is the Root cause for Class caste exception in struts frame work .and how 2 handle that 1 please help me
Connecting to a MySQL Database in Java
Connecting to a MySQL Database in Java   ... will learn how to connect the MySQL database with the Java file. Firstly, we need... on connecting to a MySQL database, after going through this program you
what is a null pointer exception in java
what is a null pointer exception in java  what is a null pointer exception in java
Java null pointer exception
Java null pointer exception  Hi I've made an array of Book objects that I made, the array is called library and it can hold 100 books, but currently...]!=null){ if(strfield.contains(param)){ result+=library[counter
connecting to timesten in web application
connecting to timesten in web application  Please give me the steps connecting to timesten in web application. Am using jsp
null pointer exceptions
null pointer exceptions  import java.util.*; public class employee { static int ch; static int emp[]; String name; int id,age; float sal; void insert() { employee[] emp=new employee[90]; Scanner r
null pointer exception in jsp
null pointer exception in jsp  index.html <html> <body> <table align=center> <form action="Login.jsp" method="get"> <tr> <td colspan=2><h1>Student Login</h1></td><
null pointer error
null pointer error  Respected sir there is a problem in this code when i add any new record in ms access data base from my code, it gives only null pointer error sir please help me my code are given below compilatation class
null pointer error
null pointer error  Respected sir there is a problem in this code when i add any new record in ms access data base from my code, it gives only null pointer error sir please help me my code are given below compilatation class
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
Java null pointer exception handling
Java null pointer exception handling   What... program? Is this extends from exception class of Java?   Java null pointer exception handling What is Java NullPointerException? In Java
Image upload in mysql database using jsp servlet
Image upload in mysql database using jsp servlet  Hello, I need code to insert image in mysql database, I have seen the code which is already in your... located inside the application, but i need to upload in mysql and also for inserting
Connecting code of reset password to database
Connecting code of reset password to database  connecting code of reset password to database
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
null pointer exception cannot be removed
null pointer exception cannot be removed  class list { public... Exception nothing; public int r; public list() { this(null,null,0); } public list(String e,int i) { this.elem = e; this.next = null
Handle Null Pointer Exception while text file upload
Handle Null Pointer Exception while text file upload  I want the code for handling null pointer exception in jsp page. That is I need an error page for null pointer exception. The cause for null pointer exception is while
jsp -sevlet connecting to database using dropdown
jsp -sevlet connecting to database using dropdown  How can I get my dropdown list from oracle database and then submit it to another table in JSP. I... to a servlet which then inserts to the database. someone please give me some sample
mysql query for null value
mysql query for null value   What mysql query for null value i need to write to display message when no data in database? Please help.Thanks!   if(mysql_num_rows($data2) > 0){ //while loop goes here } else
Connecting to remote mysql server using jdbc.
Connecting to remote mysql server using jdbc.  How to Connect to remote mysql server using jdbc

Ads