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

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









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
connecting jsp to mysql - JSP-Servlet
connecting jsp to mysql  Hi, i am working on 'Web application... to the mysql database through jsp. After downloading the mysql-connector-java-5.0   One jar file is needed to connect java with mysql data base. That can
null pointer
null pointer  dear sir , what is mean by null pointer in c
Null pointer exception error in Jsp - JSP-Servlet
Null pointer exception error in Jsp  Hi i write a login page. when i..." attributes in the input tag So id,userpwd gives null pointer exception... { return true; } } Web-Based Bug Tracking System
Null pointer exception error in Jsp - JSP-Servlet
Null pointer exception error in Jsp  Expert:Majid Hi i write a login..." attributes in the input tag So id,userpwd gives null pointer exception. Thanks... not be empty"); return false; } else { return true; } } Web-Based
connecting to a database dynamically - JSP-Servlet
connecting to a database dynamically   abc.html :- abc.jsp :- Above code gives the following... with database dynamically. Plz debug the code and explain the reasons for the exception
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
Connecting to Database from a hyperlink in JSP - JSP-Servlet
Connecting to Database from a hyperlink in JSP  How can I connect to database by clicking on a hyperlink in a JSP Page.Can you please give me sample... which is connect to database using jdbc database
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
what is a null pointer exception in java
what is a null pointer exception in java  what is a null pointer exception in java
Connecting to MySQL database and retrieving and displaying data in JSP page
Connecting to MySQL database and retrieving and displaying data in JSP page...; This tutorial shows you how to connect to MySQL database and retrieve the data... web application. Creating Table in the database.ADS_TO_REPLACE_1 Using a JDBC
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
Backup MySQL Database - JSP-Servlet
Backup MySQL Database  Database Sir I have been reading Rose's india tutorial "Using MySQL Database with JSP/Servlet". In the Tutorial you have shown an example of backing up the database. When I tried to backup database
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
Null Pointer Exception - Java Beginners
Null Pointer Exception  How Can I Handle NullPoiniterException without using try/catch mechanism
Null pointer exception in hibernate - Hibernate
Null pointer exception in hibernate  Hi i am getting null pointer exception.while running the program in hibernate... is compiled successfully but while running the program i am getting null ponter
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
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
Connecting to a database through the Proxy.
Connecting to a database through the Proxy.  Connecting to a database through the Proxy I want to connect to remote database using a program that is running in the local network behind the proxy. Is that possible
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
Error in connecting to the mySQL database in TOMCAT using more than one PC (database connection pooling)
Error in connecting to the mySQL database in TOMCAT using more than one PC (database connection pooling)  how do i implement connection pooling... to access the same application/database, I get a java.lang.NullPointer
connecting to database - Struts
information via the database in my web page. Thanks Tayo  Hi friend...connecting to database  Hi I am having problems with connection to MS SQL Server 2005 database. My first is what do i write in struts
doubt in connecting to mysql in flex - XML
doubt in connecting to mysql in flex  The ?Create application from... -> Create Application from Database from the main menu;Select your project... of a tipical MySql Connection Host URL: localhost Database Name:users User Name: root
doubt in connecting mysql in flex - XML
doubt in connecting mysql in flex  The ?Create application from...; Create Application from Database from the main menu;Select your project... MySql Connection Host URL: localhost Database Name:users User Name: root
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
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
connecting servlet to db2 - JSP-Servlet
connecting servlet to db2  Hello sir, Iam new to db2.so I would like to know the procedure to connect to db2 from a servlet or jsp.Also Tell me the configuration we need to be done before connecting to the db2(such as what path
Connecting to the Database Using JDBC and Pure Java driver
Connecting to the Database JDBC Driver In our search engine we are using MySQL database server and MM.MySQL Driver for connecting our application to the database. MM.MySQL Driver
Connecting code of reset password to database
Connecting code of reset password to database  connecting code of reset password to database
Null Pointer Exception
Null Pointer Exception        Null pointer exceptions are the most common run time ..., while in a Java object reference refers to an object of known type, or be null
connecting with database - Struts
connecting with database  I am creating an application where when jsp page is displayed, it contains the combo box where data is populated from the database.it has 3 buttons and the functionality for all buttons is different
Connecting JTable to database - JDBC
Connecting JTable to database  Hi.. I am doing a project on Project... interface in which i have used JTables.. Now my problem is I dont know how to how to store this JTable content in my database table.. This is a very important
Connecting Oracle database with struts - Struts
Connecting Oracle database with struts  Can anyone please provide me some solutions on Connection between Oracle database and struts
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 to access database
connecting to access database  print("code sample");Hi I Write java... this there is no error but my data is not going to my Acess Database. There is working exception which I wrote("SQL ERROR") Please help me to slove this problem. here
Why the null Pointer exception is comming? - Java Beginners
Why the null Pointer exception is comming?  My code is given below...")); String []oldOne = null; String[]newOne; int i = 0...}; String line; String line1; String[] tokens = null
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

Ads