I am using a
JSP page to connect to a Sybase DB using jConnect. It seems like I am able to connect to the DB but get a couple errors after connection. For some reason it works fine on my localhost using Netbeans but not on our Apache server. Here is my code below. I hope I put this in the correct forum.
-----------------------------------------------------------
<%@ page session="false" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.math.*" %>
<html>
<head><title>DB Connect</title></head>
<body>
<%
String DRIVER = "com.sybase.jdbc2.jdbc.SybDriver";
String URL = "jdbc:sybase:Tds:john.selco.info:2025/horizon?HOSTNAME=JavaProg";
String USER = "*********";
String PWD = "*********";
Statement stmt = null;
ResultSet rs = null;
Connection conn = null;
try {
//Step 1 - Load
JDBC Driver
Class.forName(DRIVER);
//Step 2 - Create a Connection Object
conn = DriverManager.getConnection(URL,USER,PWD);
out.println("got connection<br>");
//Step 3 - Create a statement object and obtain a ResultSet object
stmt = conn.createStatement();
StringBuffer myquery = new StringBuffer();
myquery.append("select name, location");
myquery.append(" from location");
myquery.append(" order by name");
rs = stmt.executeQuery(myquery.toString());
}
catch(Exception e) {
System.out.println(e);
out.println("<b>"+"Error"+"</b>"+" "+e);
}
try {
// print the data
while(rs.next()) {
out.println(rs.getString(1)+ " " + rs.getString(2)+ "<br>");
} // end while
}
catch(Exception e) {
System.out.println(e);
out.println("<b>"+"Error"+"</b>"+" "+e);
}
finally {
try {
if(conn != null)
// conn.close();
if(stmt != null)
stmt.close();
if(rs != null)
rs.close();
} // end try
catch(Exception e) {
System.out.println(e);
out.println("<b>"+"Error"+"</b>"+" "+e);
} // end catch
} // end finally
%>
</body>
</html>
-----------------------------------------------------------