Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have created a Dynamic web application in java,jsp and connected to MySQL server using phpMyAdmin as localhost database server.
The code for connection class:

static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost/dbtest";

static final String USER = "root";
static final String PASS = "";
Statement stmt = null;
static Connection conn = null;

public static Connection getConnection() {

try {
Class.forName("com.mysql.jdbc.Driver");
System.out

System.out.println("Connecting to database...");
conn = DriverManager.getConnection(DB_URL, USER, PASS);

} catch (Exception e) {
e.printStackTrace();
}
return conn;
}

And, While hosting this application on VPS (through Plesk parallel panel for windows) i have changed the DB_URL to my server ip address:port and uploaded on server using .WAR file.

When i am trying to print conn object to check if the connection is establishing with database i got the object value and

connection was successful and all database operation are working well.

The issue i faced after hosting .war file is, conn object is returning null and my application gives 500 internal server

error.

can anyone suggest where iam going wrong and how to connect to database while hosting it.


Thank you.
Posted
Comments
ZurdoDev 8-Sep-15 16:02pm    
Sounds like you need to troubleshoot with your hoster.
suman sgs 9-Sep-15 1:30am    
Thank you. But probably what might be the problem? Any idea ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900