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.