I have made a JSP website in NetBeans which I tried and tested on my local server through tomcat(using access database) and it worked fine. My web host has provided me the host, database name, username and password of the database. I want to configure my website to use this database. But I don't know how to do that. I have seen the system.properties file in web-inf/config folder whose content are like this:
JNDI_NAME=java:com/env/Oracle/jndi
db.login=
db.password=
driver=sun.jdbc.odbc.JdbcOdbcDriver
url=jdbc:odbc:mydb
duser=
dpass=
logfile=log/aoc_log.txt
dbname=my_db
But I am confused how to modify this file. Also, the database is only accessible from the web host.
Below code shows how connection is made (I think so...)
public Connection getConnection()
{
try
{
if(con==null)
{
try
{
Properties p = getProperties();
Class.forName(p.getProperty("driver"));
System.out.println("Driver loaded");
con = DriverManager.getConnection(p.getProperty("url"),p.getProperty("duser"),p.getProperty("dpass"));
System.out.println("Connection established");
}
catch (ClassNotFoundException cnf)
{
LoggerManager.writeLogWarning(cnf);
}
}
}
catch (SQLException sqlex)
{
sqlex.printStackTrace();
LoggerManager.writeLogSevere(sqlex);
}
return con;
}