essa classe e a parte do servidor e contem um sevico que chama a classe conexao
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package src;
import persistencia.Conexao;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
/**
*
* @author Ruan
*/
@WebService()
public class Teste {
@WebMethod(operationName = "Logar")
public boolean Logar(@WebParam(name = "matrucla")
String matrucla, @WebParam(name = "senha")
String senha) {
//TODO write your implementation code here:
Conexao c = new Conexao();
c.conexao();
//verifica se teve algum aluno
boolean vefificador = c.selecionarusuario(matrucla, senha);
return vefificador;
}
}
classe conexao
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package src;
import persistencia.Conexao;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
/**
*
* @author Ruan
*/
@WebService()
public class Teste {
@WebMethod(operationName = "Logar")
public boolean Logar(@WebParam(name = "matrucla")
String matrucla, @WebParam(name = "senha")
String senha) {
//TODO write your implementation code here:
Conexao c = new Conexao();
c.conexao();
//verifica se teve algum aluno
boolean vefificador = c.selecionarusuario(matrucla, senha);
return vefificador;
}
}
essa segunda parte é o projeto j2me no metodo “public void method()” ele chama o web service atraves do metodo 'logar" que retorna um boolean
e dependendo do valor do boolean ele encaminha para um fluxo do programa
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package hello;
import java.rmi.RemoteException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import org.netbeans.microedition.lcdui.LoginScreen;
import org.netbeans.microedition.lcdui.SimpleTableModel;
import org.netbeans.microedition.lcdui.TableItem;
import testeservice.TesteService_Stub;
//import testeservice.TesteService_Stub;
/**
* @author Ruan
*/
public class HelloMIDlet extends MIDlet implements CommandListener {
private boolean midletPaused = false;
//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">
private Command okCommand1;
private Command exitCommand1;
private Command exitCommand;
private Command okCommand;
private Alert alert1;
private LoginScreen loginScreen;
private Alert alert;
//</editor-fold>
/**
* The HelloMIDlet constructor.
*/
public HelloMIDlet() {
}
//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">
/**
* Initilizes the application.
* It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
*/
private void initialize() {
// write pre-initialize user code here
// write post-initialize user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">
/**
* Performs an action assigned to the Mobile Device - MIDlet Started point.
*/
public void startMIDlet() {
// write pre-action user code here
switchDisplayable(null, getLoginScreen());
// write post-action user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">
/**
* Performs an action assigned to the Mobile Device - MIDlet Resumed point.
*/
public void resumeMIDlet() {
// write pre-action user code here
// write post-action user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">
/**
* Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
* @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
* @param nextDisplayable the Displayable to be set
*/
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
// write pre-switch user code here
Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}
// write post-switch user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">
/**
* Called by a system to indicated that a command has been invoked on a particular displayable.
* @param command the Command that was invoked
* @param displayable the Displayable where the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {
// write pre-action user code here
if (displayable == alert) {
if (command == exitCommand1) {
// write pre-action user code here
exitMIDlet();
// write post-action user code here
}
} else if (displayable == alert1) {
if (command == okCommand1) {
// write pre-action user code here
switchDisplayable(null, getLoginScreen());
// write post-action user code here
}
} else if (displayable == loginScreen) {
if (command == LoginScreen.LOGIN_COMMAND) {
// write pre-action user code here
method();
// write post-action user code here
}
}
// write post-action user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">
/**
* Returns an initiliazed instance of exitCommand component.
* @return the initialized component instance
*/
public Command getExitCommand() {
if (exitCommand == null) {
// write pre-init user code here
exitCommand = new Command("Exit", Command.EXIT, 0);
// write post-init user code here
}
return exitCommand;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: method ">
/**
* Performs an action assigned to the method if-point.
*/
public void method() {
// boolean x = true;
TesteService_Stub teste = new TesteService_Stub();
boolean verificador = false;
try {
verificador = teste.logar(loginScreen.getUsername(),loginScreen.getPassword());
} catch (RemoteException ex) {
ex.printStackTrace();
}
// enter pre-if user code here
if (verificador) {
// write pre-action user code here
switchDisplayable(null, getAlert());
// write post-action user code here
} else {
// write pre-action user code here
switchDisplayable(null, getAlert1());
// write post-action user code here
}
// enter post-if user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: loginScreen ">
/**
* Returns an initiliazed instance of loginScreen component.
* @return the initialized component instance
*/
public LoginScreen getLoginScreen() {
if (loginScreen == null) {
// write pre-init user code here
loginScreen = new LoginScreen(getDisplay());
loginScreen.setLabelTexts("Nome de usu\u00E1rio", "Senha");
loginScreen.setTitle("loginScreen");
loginScreen.addCommand(LoginScreen.LOGIN_COMMAND);
loginScreen.setCommandListener(this);
loginScreen.setBGColor(-3355444);
loginScreen.setFGColor(0);
loginScreen.setUseLoginButton(false);
loginScreen.setLoginButtonText("Logon");
// write post-init user code here
}
return loginScreen;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">
/**
* Returns an initiliazed instance of okCommand component.
* @return the initialized component instance
*/
public Command getOkCommand() {
if (okCommand == null) {
// write pre-init user code here
okCommand = new Command("Ok", Command.OK, 0);
// write post-init user code here
}
return okCommand;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert ">
/**
* Returns an initiliazed instance of alert component.
* @return the initialized component instance
*/
public Alert getAlert() {
if (alert == null) {
// write pre-init user code here
alert = new Alert("alert", "MATRICULA E SENHA CORRETA!!!!!!!", null, null);
alert.addCommand(getExitCommand1());
alert.setCommandListener(this);
alert.setTimeout(Alert.FOREVER);
// write post-init user code here
}
return alert;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand1 ">
/**
* Returns an initiliazed instance of okCommand1 component.
* @return the initialized component instance
*/
public Command getOkCommand1() {
if (okCommand1 == null) {
// write pre-init user code here
okCommand1 = new Command("Ok", Command.OK, 0);
// write post-init user code here
}
return okCommand1;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert1 ">
/**
* Returns an initiliazed instance of alert1 component.
* @return the initialized component instance
*/
public Alert getAlert1() {
if (alert1 == null) {
// write pre-init user code here
alert1 = new Alert("alert1", "Login ou senha errado", null, null);
alert1.addCommand(getOkCommand1());
alert1.setCommandListener(this);
alert1.setTimeout(Alert.FOREVER);
// write post-init user code here
}
return alert1;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand1 ">
/**
* Returns an initiliazed instance of exitCommand1 component.
* @return the initialized component instance
*/
public Command getExitCommand1() {
if (exitCommand1 == null) {
// write pre-init user code here
exitCommand1 = new Command("Sair", Command.EXIT, 0);
// write post-init user code here
}
return exitCommand1;
}
//</editor-fold>
/**
* Returns a display instance.
* @return the display instance.
*/
public Display getDisplay () {
return Display.getDisplay(this);
}
/**
* Exits MIDlet.
*/
public void exitMIDlet() {
switchDisplayable (null, null);
destroyApp(true);
notifyDestroyed();
}
/**
* Called when MIDlet is started.
* Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
*/
public void startApp() {
if (midletPaused) {
resumeMIDlet ();
} else {
initialize ();
startMIDlet ();
}
midletPaused = false;
}
/**
* Called when MIDlet is paused.
*/
public void pauseApp() {
midletPaused = true;
}
/**
* Called to signal the MIDlet to terminate.
* @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
*/
public void destroyApp(boolean unconditional) {
}
}
não da nenhum erro quando executo no netbeans ele funciona divinamente quando coloco uma matricula e senha errada ele encaminha para uma tela e quando coloco o login e senha correto ele encaminha para outra tela
mais quando coloco no meu celular que é um n97 ele execulta ai aparece a tela inicial que devo digitar nome e senha do usuario ai aperto o botao logar ai o telefone pergunta se deseja permitir que o aplicativo use a ede e envie ou receba dados ai coloco a opcao permitir nesta sessao
mais ai ele trava n passa pra outra tela