Dear Sir/mam,
I have designed the trial version for my standalone
java application, i compared the system date with user's registration date when the user installs the software, the problem came in as the user changes the system date the expiry date of the software advances or can be said is affected,can any one help me in solving my problem,so that i can make my java application free of the changes made in the system date.My code goes like this , please check, exact solutions will be highly appreciated thank you.
// code for demo version to compare date
String dateQuery = "SELECT (TO_DAYS(SYSDATE())- TO_DAYS(regdate)) DATEDIFF FROM registration WHERE name='"
+ name + "' AND password='" + password + "' ";
// System.out.println(dateQuery);
st1 = (Statement) connection.createStatement();
rs1 = (ResultSet) st1.executeQuery(dateQuery);
if (rs1.next()) {
String diffdate = rs1.getString(1);
System.out.println(diffdate);
int i = Integer.valueOf(diffdate).intValue();
System.out.println(i);
if (i <= 15)
{
int j = 0;
// System.out.println(i);
// String strQuery1 =
// "select date from registration ";
// System.out.println("today's date");
String strQuery = "select * from registration where name='"
+ name
+ " 'AND password='"
+ password
+ "'";
st = (Statement) connection.createStatement();
rs = (ResultSet) st.executeQuery(strQuery);
if (rs.next()) {
if (rs.getString(1).equalsIgnoreCase(name)
&& rs.getString(9).equalsIgnoreCase(
password)) {
cst = rs.getString(13);
kst = rs.getString(14);
System.out.println("" + name);
System.out.println("" + cst);
System.out.println("" + kst);
session.put("username", name);
session.put("cst", cst);
session.put("kst", kst);
System.out.println(""
+ session.get("username"));
System.out.println("" + session.get("cst"));
System.out.println("" + session.get("kst"));
System.out.println("hello");
return "success";
}
}
}
else {
System.out.println("today's date else block");
request.setAttribute("message",
"Trial version expired");
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("C://Program Files/Apache Software Foundation/Tomcat 6.0/webapps/Pharma/batch.bat");
return "failure";
}
}
else {
request.setAttribute("message",
"username and password do not match");
return "failure";
}