Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Servlet connection to MS SQL

    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;
    Class.forName("com.internetcds.jdbc.tds.Driver");
    System.out.println("Before Connection " );
    java.sql.Connection Conn = (java.sql.Connection)java.sql.DriverManager.getConnection("jdbc:freetds:sqlserver:SQLServer","sa","p assword");

    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()) {
    System.out.println(rs.getString(1));
    }

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

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did you cross posted this under a different name (= twocool ) in the MySQL forum ?

    Please do not crosspost.

    Why different name/user?

  • #3
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oops haha i did not cross post
    but i happen to ask him the same question b4 posting to this forum.
    so i guessed he helped me by posting it here without noeing that i posted it too. sorry if this incident created any problems for anyone.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •