tomcat setting for context

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rohitrohitrohit
    New Member
    • Oct 2007
    • 18

    tomcat setting for context

    hello,
    i am rohit.i am a beginner.i installed tomcat 5.0.28 in my window xp sev-2.i also test some servlets and jsp and html page which executed well.

    i installed my tomcat in- c:\tomcat 5.0
    my problem is that i make a login servlet which check for valid user and if they are valid the servets process forward.

    but i am getting this error-
    java.sql.SQLExc eption: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified .

    i saw related topics in googel for setting my server.xml file.

    but i did not understand.so plz. solve my problems.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by rohitrohitrohit
    hello,
    i am rohit.i am a beginner.i installed tomcat 5.0.28 in my window xp sev-2.i also test some servlets and jsp and html page which executed well.

    i installed my tomcat in- c:\tomcat 5.0
    my problem is that i make a login servlet which check for valid user and if they are valid the servets process forward.

    but i am getting this error-
    java.sql.SQLExc eption: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified .

    i saw related topics in googel for setting my server.xml file.

    but i did not understand.so plz. solve my problems.
    You need the MySQL driver added and set in the classpath for your servlets. You also apparently did not specify the database to connect to!

    Comment

    • rohitrohitrohit
      New Member
      • Oct 2007
      • 18

      #3
      Originally posted by r035198x
      You need the MySQL driver added and set in the classpath for your servlets. You also apparently did not specify the database to connect to!

      sir, i have installed sql 2005 in my system. and i installed tomcat 5.0.28 in c:\tomcat 5.0

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by rohitrohitrohit
        sir, i have installed sql 2005 in my system. and i installed tomcat 5.0.28 in c:\tomcat 5.0
        Where did you put the driver for accessing the sql server database?
        Post also the code you used for the connection to the database.

        Comment

        • rohitrohitrohit
          New Member
          • Oct 2007
          • 18

          #5
          Originally posted by r035198x
          Where did you put the driver for accessing the sql server database?
          Post also the code you used for the connection to the database.


          sir,i am using j2sdkee1.2.1 with jdk1.3 to deploy my servlets and jsp.
          sir, this code i written below works well and no error come.
          but it take's a long procedure to deploy servlet and jsp.

          so,i decided to use tomcat 5.0.28 and i red it's Basic concept.i installed it in my window xp.i downloaded exe from internet.
          i am using sql2005 as my database.i tried some simple servlets,jsp(wh ich does not required database connection), it executed in my
          system.

          i also set my envirnment variable-i installed tomcat5.0.28 in (Drive) C:\tomcat5.0.28
          CATALINA_HOME-C:\Tomcat 5.0
          JAVA_HOME-C:\j2sdk1.4.0_0 4
          CLASSPATH-C:\Tomcat 5.0\common\lib\ ant.jar;C:\Tomc at 5.0\common\lib\ servlet-api.jar;C:\Tomc at 5.0\common\lib\ jsp-api.jar;C:\Tomc at 5.0\common\lib\ tools.jar


          but when i am executing same code written below with tomcat 5.0.28 it generating
          error-
          "java.sql.SQLEx ception: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified "

          i created my Directory structure under webapp folder as-
          1) MYSite
          --WEB-INF
          --web.xml
          * --classes
          --lib
          2) META-INF



          public void doPost(HttpServ letRequest req,HttpServlet Response res)
          throws ServletExceptio n,IOException
          {
          String Login=req.getPa rameter("txtnam e");
          String Password=req.ge tParameter("txt password");


          try
          {

          Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
          Connection con=DriverManag er.getConnectio n("Jdbc:Odbc:my registration"," sa","administra tor123");
          PreparedStateme nt pstat=con.prepa reStatement("se lect * from registration where firstname=? and password=?");
          pstat.setString (1,Login);
          pstat.setString (2,Password);
          ResultSet rs=pstat.execut eQuery();
          if(rs.next())
          {

          ServletContext context=getServ letContext();
          context.setAttr ibute("LoginNam e",Login);

          RequestDispatch er dispatcher=req. getRequestDispa tcher("/UserPageServlet ");
          dispatcher.incl ude(req,res);
          }
          else
          {
          ............... .........
          }
          catch(Exceptin e)
          {
          ...........
          }

          Comment

          • rohitrohitrohit
            New Member
            • Oct 2007
            • 18

            #6
            can some one help me in this topic?

            Comment

            Working...