View Full Version : SQL.... i havin problems

03-27-2003, 07:01 AM
hi guys....... i am having problems connecting to the sql server using java servlet. I think it may be due to the configuration of the userid and password in the ODBC settings. Here is my code below
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.internetcds.jdbc.tds.*;

public class sample extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
try {
System.out.println("Before Class " );
PrintWriter out=null;
System.out.println("Before Connection " );
java.sql.Connection Conn = (java.sql.Connection)java.sql.DriverManager.getConnection("jdbc:freetds:sqlserver:SQLServer","sa","password");

System.out.println("Before Statement" );
java.sql.PreparedStatement st = (java.sql.PreparedStatement)Conn.prepareStatement("select * from test");
java.sql.ResultSet rs = st.executeQuery();
while(rs.next()) {

} catch(Exception e) {
this code dun seem to be able to run ("jdbc:freetds:sqlserver:SQLServer","sa","password");
please advice......... thanx

03-27-2003, 08:57 AM

This is probably not the right formum. (MySQL database !) But heres a tutorial with working code

edit : Please do not crosspost.
Did you steel this post from someone or did you create a different user for the other post + why then?