Servlet problem

Servlet problem

Hello,

I am very shocked about this mysterious problem from last three month and now i hope rose india developers will definitely help me.

I built a web application using jsp, servlets . My web application is working well on my local host but when i try upload my websystem at a hosting site . Servlet page give blank page and exception "java.sql.SQLException: [unixODBC][Driver Manager]Data source name not found, and no default driver specified"

I have latest jdbc connector in server lib dir and also i have configured server.xml and config.xml according to instructions given by different forums. It is quite strange when i point webpage to other jsp page having same database connectivity code it works but problem is with servlet page.

My servlet code is below

package record;
import javax.swing.*;
import java.io.IOException;
import java.io.PrintStream;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.swing.JOptionPane;

public class MyServlet extends HttpServlet
{

public MyServlet()
{
}

protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
{
    processRequest(request, response);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
{
    processRequest(request, response);
}

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
{
    String id = request.getParameter("userid");
    String pwd = request.getParameter("pwd");
    HttpSession s = request.getSession();
    s.setAttribute("named", id);
    Calendar c1 = Calendar.getInstance();
    String DATE_FORMAT_NOW = "HH:mm:ss";
    Date datee = new Date();
    SimpleDateFormat sdaf = new SimpleDateFormat("dd");
    SimpleDateFormat sdaf2 = new SimpleDateFormat("MM");
    SimpleDateFormat sdaf3 = new SimpleDateFormat("yyyy");
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
    String date = sdaf.format(datee);
    String month = sdaf2.format(datee);
    String year = sdaf3.format(datee);
    String name = null;
    String passwrd = null;
    String lastdate = null;
    String lastmonth = null;
    String lastyear = null;
    int flag = 0;
   /* String url= 
"jdbc:jtds:sqlserver://db205.my-hosting-panel.com/cte123_dictionary";
String ids= "cte123_dictionary";
String pass = "pass123";*/
     try
    {

//String url= 
//"jdbc:sqlserver://204.93.178.157 ;" + "databasename=cte123_dictionary;user= cte123_dictionary;password = pass123;";

Class.forName("com.mysql.jdbc.Driver"); 
String url = "jdbc:mysql://127.0.0.1:3307/ctesystems?auto_Reconnect=true";
System.out.println("Driver Loaded");
//Class.forName("com.mysql.jdbc.Driver"); 

String username="ctesystems";
String password="pass";
Connection con = java.sql.DriverManager.getConnection(url,username,password);


         //con = java.sql.DriverManager.getConnection(url);
       // Connection con = DriverManager.getConnection(url);
        Statement st = con.createStatement();
        ResultSet rs = null;
        String sql = "SELECT * FROM login ";
        rs = st.executeQuery(sql);
        do
        {
            if(!rs.next())
                break;
            name = rs.getString("names");
            passwrd = rs.getString("password");
            lastdate = rs.getString("last_date");
            lastmonth = rs.getString("last_month");
            lastyear = rs.getString("last_year");
            //System.out.println(id);
            //System.out.println(name);
           // System.out.println(pwd);
           // System.out.println(passwrd);
            if(id.equals(name) && pwd.equals(passwrd))
            {

                flag = 1;
                break;
            }
            if(date.equals(lastdate) && month.equals(lastmonth) && year.equals(lastyear))
            {

                JOptionPane.showMessageDialog(null, "Your account session has expired.Please contact your consultant!");
                flag = 2;
                break;
            }
            else{

            flag = 2;}
        } while(true);
        //System.out.println(flag);
        if(flag == 2)
            response.sendRedirect("register.jsp");
        else
            response.sendRedirect("welcome.jsp");
        con.close();
}
    catch(Exception sqlEx)
    {
        sqlEx.printStackTrace();
       // System.out.println(sqlEx);
        response.sendRedirect("register.jsp");
    }
}
}
View Answers

Ads









Related Tutorials/Questions & Answers:
Servlet problem
connectivity code it works but problem is with servlet page. My servlet code...Servlet problem  Hello, I am very shocked about this mysterious problem from last three month and now i hope rose india developers
servlet problem
servlet problem  wheni m deploying an servlet application im getting trouble context [/filename] startup failed due to previous error in tomcat 6.0.
Advertisements
problem in servlet program
problem in servlet program  Dear Sir, I have a problem to insert the Blob type data like as video file, audio file in the database using Servlet and html code
Java Servlet Problem - JSP-Servlet
Java Servlet Problem  I have a servlet class that implemets..., but in the attributeReplaced() method, i want to perform a redirect to another servlet... method. Please help!!  Hi friend, Please explain problem
problem running a servlet on tomcat.
problem running a servlet on tomcat.  i have followed the steps given... to run my servlet that is placed in the directories as it has been mentioned here... be the problem? please help me out
java servlet connectivity problem with access
java servlet connectivity problem with access  Import java.sql javax.servlet //all packages entered try { Class.forName...=con.createStatement(); ^ i am confused what is the problem
servlet redirect problem help needed
servlet redirect problem help needed  package p; import...=getServletContext().getRequestDispatc‚?¶ re.forward(req, resp); } } this servlet is calling by a jsp..there is no problem,in this servlet the if condition always
servlet redirect problem help needed
servlet redirect problem help needed  package p; import...=getServletContext().getRequestDispatc‚?¶ re.forward(req, resp); } } this servlet is calling by a jsp..there is no problem,in this servlet the if condition always
problem at the time of execution - JSP-Servlet
problem at the time of execution  when i was running web applications the exception i.e 404 resource is not available what it means and where it occures what is the solution   Hi Friend, This error occurs when
problem in record viewing in jsp - JSP-Servlet
and servlet and back end mysql actually what is my problem is i have to everytime...problem in record viewing in jsp  hai i send the code can you please find where is the problem it is not showing any error but i cannot able to view
Problem in record viewing in jsp - JSP-Servlet
Problem in record viewing in jsp  hai i have developed... . no problem all are working but in view part alone some problem i dont know what... please help me how to solve this problem i am not getting any error
problem in creating web application using servelet, jsp, jdbc and xml - JSP-Servlet
problem in creating web application using servelet, jsp, jdbc and xml  Using Servlet, JSP, JDBC and XML create a web application for a courrier...; Hi friend, For solving the problem visit to : http://www.roseindia.net
apache tomcat problem - JSP-Servlet
JSP code problem - JSP-Servlet
servlet
servlet  hi sir,this is ashok.i installed tomcat 6.0 and jdk-150.i checked the server it's working but when execute servlet program for the .class... sir hoew to resolve this problem
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Null pointer exceptation-Java Servlet web application,Problem connecting...,since i try to configure this out for 1 week,i dont find any solution for my problem... the project in WAR file and then i upload to my hosting. The problem come when my
Servlet
Servlet  how to navigate one servlet page to another servlet page
servlet
servlet  is there any way to include pdf's in servlet
servlet
servlet  what are the methods and interfaces in the servlet api ?   Servlet Tutorials
servlet
servlet  what are the all necessary configuration to run a servlet
servlet
servlet  how to interact with a servlet from a swing program
servlet
servlet  I designed 1 html form & a servlet but when I click on form I don't get output of servlet Please help
servlet
servlet  I designed 1 html form & a servlet but when I click on form I don't get output of servlet Please help
servlet
servlet  i want to create a login page with servlet using database mysql? only in servlet not in jsp plzz help me out
Servlet
override Service method in the servlet when you extend GenericServlet to create servlet as it is mandatory to override it. But, when you extend HttpServlet to create a servlet then you can't override service method as there is a need to override
servlet
servlet  i want a program for counting the no of times the servlet has been invoked
servlet
servlet  how to create a login form using servlet using submit,edit delete button
servlet
servlet  dear sir servlet and html not run on eclips plz help me
servlet
servlet  can i stoar record in variable which selected from table in servlet
servlet
of the Servlet API. It contains the classes necessary for a standard, protocol-independent servlet. Every servlet must implement the Servlet interface in one
Servlet
Servlet  I want to know the steps to write a simple servlet program... .   Hello Friend, Follow these steps: Put servlet-api.jar inside the lib folder of apache tomcat. 1)create a servlet. import java.io.*; import

Ads