
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");
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.