Skip to Content.
Sympa Menu

freetds - Re: Need help!!!

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Ted Munnich" <tmunnich AT idexsoft.com>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: Re: Need help!!!
  • Date: Thu, 16 Aug 2001 17:49:08 -0400


Curt, thank you for your quick response. I also tried the following code,
which gives me the same error message.

// filename sqltest.java
package test;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class sqltest extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
Connection con = null;
Statement st = null;
ResultSet rs = null;

res.setContentType("text/html");
PrintWriter out = res.getWriter();

try
{
String sUrl =
"jdbc:freetds:sqlserver://192.168.1.2:1433/Northwind";
String sLogin = "sa";
String sPassword = "";
String sQuery = "select * from employees";

Class.forName("com.internetcds.jdbc.tds.Driver");
Connection con =
DriverManager.getConnection(sUrl, sLogin, sPassword);

st = con.createStatement();
rs = st.executeQuery(sQuery);

out.println("<html><head><title>SQL Test</title></head>");
out.println("<body>");
out.println("<ul>");

while(rs.next())
{
out.println("<li>" + rs.getString("lastname"));
}

out.println("/ul>");
out.println("</body></html>");
}
catch (ClassNotFoundException e)
{
out.println("Could not load database driver: " + e.getMessage());
}
catch (SQLException e)
{
out.println("SQLException caught: " + e.getMessage());
}
finally
{
try
{
if (con != null) con.close();
}
catch (SQLException ignored)
{
}
}
}
}




Archive powered by MHonArc 2.6.24.

Top of Page