package com.uis.loginuser.server;
import com.uis.loginuser.client.GreetingService;
import com.uis.loginuser.shared.FieldVerifier;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import java.net.ConnectException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
//import com.client.GreetingService;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet
implements
GreetingService {
Connection con=null;
Statement st=null;
ResultSet rs=null;
//jdbc:mysql://your.database.domain/yourDBname
//String url="jdbc:mysql://localhost:10081/phpMyAdmin";
String url="jdbc:mysql://
192.168.2.23:8888/mydb";
public void call()
{
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch (Exception e) {
e.printStackTrace();
}
try
{
con=DriverManager.getConnection(url, "root", "");
st=con.createStatement();
}
catch(SQLException ex)
{
//System.out.println(ex.getMessage());
}
}
public String check(String s1, String s2) {
String ss="no";
call();
try
{
rs = st.executeQuery("select * from login where name='" + s1 + "'
and password='" + s2+"'" );
if(rs.next())
{
ss="yes";
System.out.println(rs.getString(0));
System.out.println(rs.getString(1));
}
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
return ss;
}
@Override
public String newuser(String name, String password) {
String ss = "no";
call();
try
{
boolean ss1;
ss1 = st.execute("insert into login values('" + name+"','"+
password +"')");
if(ss1)
{
ss="yes";
}
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
return ss;
}
}