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 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2003
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL.... i havin problems

    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
    ("jdbc:freetds:sqlserver:SQLServer","sa","password");
    This is probably not the right formum. (MySQL database !) But heres a tutorial with working code
    http://www.javaalmanac.com/egs/java....SqlServer.html


    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?
    Last edited by raf; 03-27-2003 at 10:35 AM.


  •  

    Posting Permissions

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