如何在RCP应用程序中将mysql与ECLIPSE连接 [英] How to connect mysql with ECLIPSE in RCP application

查看:62
本文介绍了如何在RCP应用程序中将mysql与ECLIPSE连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我不知道如何在RCP应用程序中将 mysql 与ECLIPSE连接起来。请在RCP应用程序中向我发送连接 mysql sever 和ECLIPSE的示例代码。

编码部分:

RCP应用代码:

类ApplicationActionBarAdvisor :


import org.eclipse.jface.action.Action;

import org.eclipse.jface.action.IMenuManager;

import org.eclipse.jface.action.MenuManager;

import org.eclipse.jface.action.Separator;

import org.eclipse.ui。 IWorkbenchActionConstants;

import org.eclipse.ui.IWorkbenchWindow;

import org.eclipse.ui.actions.ActionFactory;

import org.eclipse .ui.actions.ActionFactory.IWorkbenchAct ion;

import org.eclipse.ui.application.ActionBarAdvisor;

import org.eclipse.ui.application.IActionBarConfigurer;


公共类ApplicationActionBarAdvisor扩展ActionBarAdvisor {


私有Action addmember;


public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {

super(configurer);

}


protected void makeActions(IWorkbenchWindow window){


addmember = new Addmember(" Add a会员,窗口;

注册(addmember);


}


protected void fillMenuBar(IMenuManager menuBar )$

MenuManager文件=新的MenuManager(& File",IWorkbenchActionConstants.M_FI LE);

MenuManager会员=新的MenuManager(&&& ;会员",null);

menuBar.add(文件);

File.add(会员);

Member.add(addmember) );

}

}

班级Addmember:


import org .eclipse.jface.action.Action;

import org.eclipse.ui.IWorkbenchWindow;


公共类Addmember extends Action {


私有IWorkbenchWindow窗口;

// public static boolean internalCall = false;


// public Addmember(){};


public Addmember(字符串字符串,IWorkbenchWindow窗口){

// TODO自动生成的构造函数存根

super(字符串);

this.window =窗口;


setId(ICommandIds.CMD_OPEN_MESSAGE);

//将动作与一个预定义的命令,允许键绑定。

setActionDefinitionId(ICommandIds.CMD_OPEN_MESSAGE);


}


public void run(){


addmemdialog d = new addmemdialog(window);

d.open();


}


}

类addmemdialog:


import org.eclipse.jface.dialogs.MessageDialog;

import org.eclipse.jface.window.ApplicationWindow;

import org.eclipse.swt .SWT;

import org.eclipse.swt.events.MouseEvent;

import org.eclipse.swt.events.MouseListener;

import org.eclipse.swt.layout.GridLayout;

import org.eclipse.swt.widgets.Button;

import org.eclipse.swt.widgets.Composite;

import org.eclipse.swt.widgets.Control;

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt .widgets.Label;

import org.eclipse.swt.widgets.Shell;

import org.eclipse.swt.widgets.Text;

import org.eclipse.ui.IWorkbenchWindow;


public class addmemdialog extends ApplicationWindow {


public addmemdialog(IWorkbenchWindow window){<< br / >
super(window.getShell());

// TODO自动生成的构造函数存根

}


@Override

protected void configureShell(Shell shell){

// TODO自动生成的方法存根

super.configureShell(shell);

shell.setText(" Add a Member");

}


public void run(){

// TODO自动生成方法存根

setBlockOnOpen (true);

open();

Display.getCurrent()。dispose();

}

protected Control createContents(复合父级){


final Composite composite1 = new Composite(parent,SWT.BORDER);

composite1.setBounds (10,10,270,250);

composite1.setLayout(new GridLayout(2,true));

标签ID =新标签(composite1,SWT.NONE);

ID.setText(" User ID:");

final text tID = new Text(composite1,SWT.BORDER);

tID .setTextLimit(30);

标签名称=新标签(composite1,SWT.NONE);

name.setText(" User name:");

final text tname = new Text(composite1,SWT.BORDER) ;

tname.setTextLimit(30);

Label pwd = new Label(composite1,SWT.NONE);

pwd.setText(" ;密码:");

final文本tpwd =新文本(composite1,SWT.BORDER);

tpwd.setEchoChar(''*'');

tpwd.setTextLimit(10);

标签cpwd =新标签(composite1,SWT.NONE);

cpwd.setText("确认密码:");

final text tcpwd = new Text(composite1,SWT.BORDER);

tcpwd.setEchoChar(''*'');

tcpwd.setTextLimit(10);

Label dno = new Label(composite1,SWT.NONE);

dno.setText("门号:" ;);

final文本tdno =新文本(composite1,SWT.BORDER);

tdno.setTextLimit(30);

Label loc = new Label(composite1,SWT.NONE);

loc.setText(" Locality:");

final text tloc = new Text(composite1,SWT.BORDER);

tloc.setTextLimit(30);

Label city = new Label(composite1,SWT.NONE) );

city.setText(" City:");

final text tcity = new Text(composite1,SWT.BORDER);

tcity.setTextLimit(30);

Label pin = new Label(composite1,SWT.NONE);

pin.setText(" Pincode:");

final文本tpin = new Text(composite1,SWT.BORDER);

tpin.setTextLimit(30);

Label state = new Label (composite1,SWT.NONE);

state.setText(" State:");

final text tstate = new Text(composite1,SWT.BORDER);

tstate.setTextLimit(30);

Label phno = new Label(composite1,SWT.NONE);

phno.setText("电话号码:");

final文字tphno =新文字(composite1,SWT.BORDER);

tphno.setTextLimit(30);

标签dtj =新标签(composite1,SWT.NONE);

dtj.setText(" Date)加入:);

final text tdtj = new Text(composite1,SWT.BORDER);

tdtj.setTextLimit(30);


按钮btnsubmit = new按钮(composite1,SWT.PUSH);

btnsubmit.setText(" Submit");

按钮btncancel = new按钮(composite1,SWT.PUSH);

btncancel.setText(" Cancel");


btnsubmit.addMouseListener(new MouseListener ()
public void mouseDoubleClick(MouseEvent e){

// TODO自动生成方法存根


}


public void mouseDown(MouseEvent e){

// TODO自动生成的方法存根

if(tID。 getText()=="" || tname.getText()=="" || tpwd.getText()=="" || tcpwd.getText()=="" || tdno.getText()=="" || tloc.getText()=="" || tcity.getText()=="" || tpin.getText()=="" || tstate.getText()=="" || tphno.getText()=="" || tdtj.getText()==""){

MessageDialog .openInformation(composite1.getShell(),&qu ot;信息",你必须输入所有字段;)

}

else if(!tpwd.getText()。equals(tcpwd.getText( ))){

MessageDialog.openInformation(composite1.getShell()," Information",您的密码和确认密码字段不匹配);

}

else

{

MessageDialog.openInformation(composite1.getShell()," User Info","您的帐户已注册" );

}


}


public void mouseUp(MouseEvent e){

// TODO自动生成方法存根

}


});


btncancel.addMouseListener(new MouseListener(){


public void mouseDoubleClick(MouseEvent e){

// TODO自动生成的方法stub
< br $>
}


public void mouseDown(MouseEvent e){

// TODO Auto-ge nerated方法stub


tID.setText("");

tname.setText("");

tpwd.setText("");

tcpwd.setText("");

tdno.setText("");

tloc.setText("");

tcity.setText("");

tpin.setText("") ;

tstate.setText("");

tphno.setText("");

tdtj.setText(" ;");


}


public void mouseUp(MouseEvent e){

// TODO Auto生成方法存根


}


});


返回父级;


}


}



这里我创建了菜单 文件 - >会员 - >添加成员当我点击我指定的项目时,屏幕上会出现标签,文字,按钮控件等...

但是当我点击时鼠标按下过程的提交按钮调用,我指定的验证代码执行。


此外,我希望在mysql数据库中更新详细信息。 Plaese给我发送连接程序....


请帮助我....

Hi

I dont know how to connect mysql with ECLIPSE in RCP application. Please send me the sample code of connecting mysql sever with ECLIPSE in RCP application.

Coding Part:

RCP Application Codes:

Class ApplicationActionBarAdvisor:

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAct ion;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

private Action addmember;

public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
}

protected void makeActions(IWorkbenchWindow window) {

addmember=new Addmember("Add a Member",window);
register(addmember);

}

protected void fillMenuBar(IMenuManager menuBar) {

MenuManager File=new MenuManager("&File",IWorkbenchActionConstants.M_FI LE);
MenuManager Member=new MenuManager("&Member",null);
menuBar.add(File);
File.add(Member);
Member.add(addmember);
}
}

Class Addmember:

import org.eclipse.jface.action.Action;
import org.eclipse.ui.IWorkbenchWindow;

public class Addmember extends Action {

private IWorkbenchWindow window;
//public static boolean internalCall = false;

//public Addmember(){ };

public Addmember(String string, IWorkbenchWindow window) {
// TODO Auto-generated constructor stub

super(string);
this.window=window;

setId(ICommandIds.CMD_OPEN_MESSAGE);
// Associate the action with a pre-defined command, to allow key bindings.
setActionDefinitionId(ICommandIds.CMD_OPEN_MESSAGE );

}

public void run() {

addmemdialog d=new addmemdialog(window);
d.open();

}

}

Class addmemdialog:

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchWindow;

public class addmemdialog extends ApplicationWindow{

public addmemdialog(IWorkbenchWindow window) {
super(window.getShell());
// TODO Auto-generated constructor stub
}

@Override
protected void configureShell(Shell shell) {
// TODO Auto-generated method stub
super.configureShell(shell);
shell.setText("Adding a Member");
}

public void run(){
// TODO Auto-generated method stub
setBlockOnOpen(true);
open();
Display.getCurrent().dispose();
}

protected Control createContents(Composite parent){

final Composite composite1 = new Composite(parent,SWT.BORDER);
composite1.setBounds(10,10,270,250);
composite1.setLayout(new GridLayout(2,true));
Label ID = new Label(composite1,SWT.NONE);
ID.setText("User ID:");
final Text tID=new Text(composite1,SWT.BORDER);
tID.setTextLimit(30);
Label name=new Label(composite1,SWT.NONE);
name.setText("User name:");
final Text tname=new Text(composite1,SWT.BORDER);
tname.setTextLimit(30);
Label pwd=new Label(composite1,SWT.NONE);
pwd.setText("Password:");
final Text tpwd=new Text(composite1,SWT.BORDER);
tpwd.setEchoChar(''*'');
tpwd.setTextLimit(10);
Label cpwd=new Label(composite1,SWT.NONE);
cpwd.setText("Confirm Password:");
final Text tcpwd=new Text(composite1,SWT.BORDER);
tcpwd.setEchoChar(''*'');
tcpwd.setTextLimit(10);
Label dno=new Label(composite1,SWT.NONE);
dno.setText("Door number:");
final Text tdno=new Text(composite1,SWT.BORDER);
tdno.setTextLimit(30);
Label loc=new Label(composite1,SWT.NONE);
loc.setText("Locality:");
final Text tloc=new Text(composite1,SWT.BORDER);
tloc.setTextLimit(30);
Label city=new Label(composite1,SWT.NONE);
city.setText("City:");
final Text tcity=new Text(composite1,SWT.BORDER);
tcity.setTextLimit(30);
Label pin=new Label(composite1,SWT.NONE);
pin.setText("Pincode:");
final Text tpin=new Text(composite1,SWT.BORDER);
tpin.setTextLimit(30);
Label state=new Label(composite1,SWT.NONE);
state.setText("State:");
final Text tstate=new Text(composite1,SWT.BORDER);
tstate.setTextLimit(30);
Label phno=new Label(composite1,SWT.NONE);
phno.setText("Phone Number:");
final Text tphno=new Text(composite1,SWT.BORDER);
tphno.setTextLimit(30);
Label dtj=new Label(composite1,SWT.NONE);
dtj.setText("Date of joining:");
final Text tdtj=new Text(composite1,SWT.BORDER);
tdtj.setTextLimit(30);

Button btnsubmit=new Button(composite1,SWT.PUSH);
btnsubmit.setText("Submit");
Button btncancel=new Button(composite1,SWT.PUSH);
btncancel.setText("Cancel");

btnsubmit.addMouseListener(new MouseListener(){

public void mouseDoubleClick(MouseEvent e) {
// TODO Auto-generated method stub

}

public void mouseDown(MouseEvent e){
// TODO Auto-generated method stub
if (tID.getText()=="" || tname.getText()=="" || tpwd.getText()=="" || tcpwd.getText()=="" || tdno.getText()=="" || tloc.getText()=="" || tcity.getText()=="" || tpin.getText()=="" || tstate.getText()=="" || tphno.getText()=="" || tdtj.getText()==""){
MessageDialog.openInformation(composite1.getShell( ), "Information", "You have to enter all the fields");
}
else if(!tpwd.getText().equals(tcpwd.getText())){
MessageDialog.openInformation(composite1.getShell( ), "Information", "Your password and confirm password fields are not matched");
}
else
{
MessageDialog.openInformation(composite1.getShell( ), "User Info", "Your account has been registered");
}

}

public void mouseUp(MouseEvent e) {
// TODO Auto-generated method stub

}

});

btncancel.addMouseListener(new MouseListener(){

public void mouseDoubleClick(MouseEvent e) {
// TODO Auto-generated method stub

}

public void mouseDown(MouseEvent e) {
// TODO Auto-generated method stub

tID.setText("");
tname.setText("");
tpwd.setText("");
tcpwd.setText("");
tdno.setText("");
tloc.setText("");
tcity.setText("");
tpin.setText("");
tstate.setText("");
tphno.setText("");
tdtj.setText("");

}

public void mouseUp(MouseEvent e) {
// TODO Auto-generated method stub

}

});

return parent;

}

}


Here i have created menu File->Member->Addmember and when i click the items which i have specified appears on the screen such as label,text,button controls etc...

But when i click the submit button the mouse down procedure invokes and the validation code which i have specified executes.

Also i want the details to be updated in mysql database. Plaese send me the connection procedure....

Please help me....

推荐答案


if(tID.getText()=="" || tname.getText()=="" || tpwd.getText()=="" || tcpwd .getText()=="" || tdno.getText()=="" || tloc.getText()=="" || tcity.getText()=="" | | tpin.getText()=="" || tstate.getText()=="" || tphno.getText()=="" || tdtj.getText()=="" ;)
[...]


我还希望在mysql数据库中更新细节。 Plaese给我发送连接程序....


请帮助我....
if (tID.getText()=="" || tname.getText()=="" || tpwd.getText()=="" || tcpwd.getText()=="" || tdno.getText()=="" || tloc.getText()=="" || tcity.getText()=="" || tpin.getText()=="" || tstate.getText()=="" || tphno.getText()=="" || tdtj.getText()==""){

[ ... ]

Also i want the details to be updated in mysql database. Plaese send me the connection procedure....

Please help me....



你不能那样的字符串;使用String.equals()方法代替或者

在这种特殊情况下你可以检查String.length()。


连接到你的数据库是和前两个帖子一样。


亲切的问候,


Jos

You can''t compary strings like that; use the String.equals() method instead or
in this particular case you can check the String.length().

Connecting to your database is the same as it was in your previous two posts.

kind regards,

Jos


你好


我想在鼠标按下程序中使用这些连接编码。但是我不能在这个RCP应用程序中使用 public static void main(String args [])抛出异常。另外我想使用throws Exception。我能做什么?当我点击提交按钮时,我希望这些连接编码工作。


请帮助我...
Hi

I want to use those connectivity codings in mouse down procedure. But i can''t use public static void main(String args[]) throws Exception, in this RCP application. Also i want to use throws Exception. What can i do? I want these connectivity codings to be worked when i click the submit button.

Please help me...






我想在鼠标按下程序中使用这些连接编码。但是我不能在这个RCP应用程序中使用 public static void main(String args [])抛出异常。另外我想使用throws Exception。我能做什么?当我点击提交按钮时,我希望这些连接编码工作。


请帮助我...
Hi

I want to use those connectivity codings in mouse down procedure. But i can''t use public static void main(String args[]) throws Exception, in this RCP application. Also i want to use throws Exception. What can i do? I want these connectivity codings to be worked when i click the submit button.

Please help me...



请重新提出您的问题;我现在能看到的当然是*不是*关于

MySQL连接。 (顺便说一句,当你发布

代码并且不要一直发布*所有*代码时,请使用那些[code] ... [/ code]标签。


亲切的问候,


Jos

Please rephrase your question; all I can see now is that it is certainly *not* about
MySQL connectivity. (btw, use those [ code ] ... [ /code ] tags when you post
code and also don''t post *all* of your code all the time).

kind regards,

Jos


这篇关于如何在RCP应用程序中将mysql与ECLIPSE连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆