My project is working fine on my local machine. I am using Private JVM hosting provided by unlimitedgb.com, The project is working fine on my eclipse with tomcat server 6 but when i deploy project on the tomcat server6 provided in NGASI Panel, it is not connecting to database. i had verified the connection string many times. i had exported mysql file as .sql file to the phpmyadmin panel provided in the control panel verified the username and password, database name and port number codded in the "dblayer.java" (myproject/Java Resources :src/com.my.classes) several times.
I am using "mysql-connector-java-5.1.26-bin.jar" as well as java jason.jar as additional libraries for my project. both files are placed on "myproject/WebContent/WEB-INF/ib/" and which is added to "myproject/Java Resources:src/Libraries/ from above location. I am also using JRE System Library [jre7] in which the "mysql-connector-java-5.1.26-bin.jar" is present by default but i had added the mysql connector as it is not present in the apache tomcat6 present at my hosting platform. the json.jar is working fine on the server in hosting platform. i had uploaded my project as war file and deployed in apache tomcat server 6 provided by hosting. there is no error showing project is deploying propely but the project is not getting connected with my database. please help me to fix this.
Write a jsp and try to hit on this
<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Start Test<br>
<% try{ %>
<%
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname","user","Passowrd");
out.println("Connected Successfully");
PreparedStatement preparedStatement=con.prepareStatement("SELECT * FROM admin");
ResultSet rst=preparedStatement.executeQuery();
while(rst.next()){
out.print("<br/>"+" "+rst.getString(1)+" "+rst.getString(2)+" "+rst.getString(3));
}
preparedStatement=con.prepareStatement("SELECT count(*),admin_id,username from admin a WHERE username='ankit' AND pwd=md5('ankit')");
rst=preparedStatement.executeQuery();
while(rst.next()){
out.print("<br/>"+" "+rst.getString(1)+" "+rst.getString(2)+" "+rst.getString(3));
}
%>
<%}catch(Throwable t) {t.printStackTrace(response.getWriter());}%>
</body>
</html>