Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


beez
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
0 Answer(s)      3 years and a month ago
Posted in : JSP-Servlet


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.


Advertisement
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
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 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 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
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
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
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
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
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 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
what is a null pointer exception in java
what is a null pointer exception in java  what is a null pointer exception in java
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
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
Null Pointer Exception - Java Beginners
Null Pointer Exception  How Can I Handle NullPoiniterException without using try/catch mechanism
Connecting to MySQL database and retrieving and displaying data in JSP page
Connecting to MySQL database and retrieving and displaying data in JSP page... web application. Creating Table in the database. Using a JDBC driver...; This tutorial shows you how to connect to MySQL database and retrieve the data
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
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
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
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
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
Advertisements
 

 

 

DMCA.com