主要由三個文件組成
用戶界面這一塊是用的eclipse的VE插件做的
//主程序
package com
public class FC {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto
Login
}
}
//用戶界面
package com
import java
import java
import org
import org
import org
import org
import org
import org
import org
import org
import org
import org
import org
public class Login {
private Shell sShell = null; // @jve:decl
private Composite composite
private Button button
private Dm dm
private Label label
private Text text
private Text text
private Text text
private Text textArea
private List list
private Button button
/**
* This method initializes composite
*
*/
private void createComposite
composite
composite
button
button
button
button
button
{
public void widgetSelected(org
{
dm
boolean c = dm
()
if (button
if (c == false) {
label
} else {
label
button
ResultSet rs=dm
());
try{
list
while(rs
for(int i=
list
}
}
}
catch(Exception ee){
ee
}
}
} else {
boolean d =dm
if (d==false){
label
}
else{
label
button
}
}
}
});
label
label
label
text
text
text
text
text
text
textArea
SWT
textArea
list
list
button
button
button
button
{
public void widgetSelected(org
{
list
ResultSetMetaData sm=dm
try{
for (int i=
list
}
}
catch(Exception ee){
ee
}
}
});
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto
/* Before this is run
(Arguments
* for the correct SWT library path in order to run with the SWT dlls
* The dlls are located in the SWT plugin jar
* For example
* installation_directory\plugins\org
*/
Display display = Display
Login thisClass = new Login();
thisClass
thisClass
while (!thisClass
if (!display
display
}
display
}
/**
* This method initializes sShell
*/
private void createSShell() {
sShell = new Shell();
sShell
sShell
sShell
/*Button btn
btn
btn
createComposite
}
}
//數據模塊
package com
import java
import java
import java
import java
import java
public class Dm {
Connection dcon;
Statement stmt;
ResultSet rs = null;
ResultSetMetaData rmd;
public boolean DconnectionOpen(String i
final String jdbc_driver =
final String database_url =
final String user = u;
final String password = p;
try{
Class
dcon = DriverManager
password);
stmt = dcon
ResultSet
}
catch (Exception e) {
e
return false;
}
return true;
}
public boolean DconnectionClose(){
try {
stmt
dcon
} catch (Exception e) {
e
return false;
}
return true;
}
public ResultSet ExeSQL(String s){
try{
rs=stmt
}
catch(Exception e){
e
}
return rs;
}
public ResultSetMetaData GetField(){
try{
rmd =rs
}
catch (Exception e){
e
}
return rmd;
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26398.html