Java application is not connecting to Database after hosting on plesk panel

Discussion in 'General Questions' started by sumans1, Sep 9, 2015.

  1. sumans1

    sumans1 Bit poster

    Messages:
    1
    I have created a Dynamic web application in java,jsp and connected to MySQL server using phpMyAdmin as localhost database server. This is the code i have written in connection class:

    staticfinalString USER ="root";staticfinalString PASS ="";Statement stmt =null;staticConnection conn =null;String JDBC_DRIVER ="com.mysql.jdbc.Driver";String DB_URL ="jdbc:mysql://localhost/dbtest";publicstaticConnection 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 on plesk panel 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.
     

Share This Page