当前位置:首页>开发>正文

Eclipse创建表格 eclipse 怎么与PL/SQL进行连接用ssm

2023-07-16 01:41:34 互联网 未知 开发

 Eclipse创建表格 eclipse 怎么与PL/SQL进行连接用ssm

Eclipse创建表格

不知道这个程序对你有没有帮助

package swt

import org.eclipse.swt.SWT
import org.eclipse.swt.custom.ControlEditor
import org.eclipse.swt.custom.TableCursor
import org.eclipse.swt.custom.TableEditor
import org.eclipse.swt.custom.ViewForm
import org.eclipse.swt.events.FocusEvent
import org.eclipse.swt.events.FocusListener
import org.eclipse.swt.events.KeyEvent
import org.eclipse.swt.events.KeyListener
import org.eclipse.swt.events.ModifyEvent
import org.eclipse.swt.events.ModifyListener
import org.eclipse.swt.events.SelectionEvent
import org.eclipse.swt.events.SelectionListener
import org.eclipse.swt.widgets.Composite
import org.eclipse.swt.widgets.Display
import org.eclipse.swt.widgets.Shell
import org.eclipse.swt.widgets.Table
import org.eclipse.swt.widgets.TableColumn
import org.eclipse.swt.widgets.TableItem
import org.eclipse.swt.widgets.Text

public class SimpleTable2 {

/**
* Launch the application
* @param args
*/
private Shell shell
private Composite composite
private ViewForm viewForm
private Table table

private void createShell(){
shell = new Shell()
shell.setSize(500, 375)
shell.setText("SWT Application")
createViewForm()
}

private void createViewForm(){
viewForm=new ViewForm(shell,SWT.NONE)
createComposite()
viewForm.setContent(composite)
viewForm.pack()
}

private void createComposite(){
composite=new Composite(viewForm,SWT.NONE)
createTable()
composite.pack()
}
private void createTable() {
table=new Table(composite,SWT.FULL_SELECTION)
table.setHeaderVisible(true)
table.setLinesVisible(true)

String[] header=

for(int i=0i<header.lengthi ){
TableColumn column=new TableColumn(table,SWT.NONE)
column.setText(header[i])
}

TableItem tableItem=new TableItem(table,SWT.NONE)
tableItem.setText(new String[])

tableItem=new TableItem(table,SWT.NONE)
tableItem.setText(new String[])

for(int i=0i<table.getColumnCount()i )
table.getColumn(i).pack()
table.pack()

//add ControlEditor on TableCursor
final TableCursor cursor=new TableCursor(table,SWT.NONE)
//cursor令使用左右键选择单元格成为可能
final ControlEditor editor=new ControlEditor(cursor)
editor.grabHorizontal=true
editor.grabVertical=true
cursor.addSelectionListener(new SelectionListener(){

public void widgetDefaultSelected(SelectionEvent e) {
//当触发此事件时才创建text(并为她添加事件),并用setFocus()把她固定住
final Text text=new Text(cursor,SWT.NONE)
TableItem row=cursor.getRow()
int column=cursor.getColumn()
text.setText(row.getText(column))
text.addKeyListener(new KeyListener(){

public void keyPressed(KeyEvent e) {
if(e.character==SWT.CR){
TableItem row=cursor.getRow()
int column=cursor.getColumn()
row.setText(column,text.getText())
text.dispose()
}
}

public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub

}

})
text.addFocusListener(new FocusListener(){

public void focusGained(FocusEvent e) {
// TODO Auto-generated method stub

}

public void focusLost(FocusEvent e) {
text.dispose() //目前认为可有可无
}

})
editor.setEditor(text)
text.setFocus() //将text固定于某个单元格上
}

public void widgetSelected(SelectionEvent e) {
table.setSelection(new TableItem[])
//当选中某行时,此行出现阴影
}

})

}

public static void main(String[] args) {
final Display display = Display.getDefault()
SimpleTable2 st=new SimpleTable2()
//
st.createShell()
st.shell.pack()
st.shell.open()
st.shell.layout()
while (!st.shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep()
}
}

}

eclipse 怎么与PL/SQL进行连接用ssm

1、运行Eclipse,新建一个Java Project 名为 Test
2、右单击src,依次选择 Build Path → Configure Build Path,在打开的窗口的右边选择 Libraries 标签,然后单击 Add External JARs,找到 sqljdbc4.jar 文件并打开,然后单击 OK 完成构建路径的配置。

3、在Test中新建包pkg,在pkg中新建一个类Main,在其中输入代码如下:
package pkg
import java.sql.*

public class Main {
public static void main(String [] args)
{
String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
String dbURL="jdbc:sqlserver://localhost:1433DatabaseName=你的数据库名"
String userName="填写你的用户名,我的是sa"
String userPwd="填写你的密码"
try
{
Class.forName(driverName)
Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd)
System.out.println("连接数据库成功")
}
catch(Exception e)
{
e.printStackTrace()
System.out.print("连接失败")
}
}
}
5、点击右键,选择 run as —> Java Application, 控制台出现下图则连接成功!

ssm框架怎么使用事务和存储过程

SSM(Spring SpringMVC MyBatis)框架集由Spring、SpringMVC、MyBatis三源框架整合作数据源较简单web项目框架
  其spring轻量级控制反转(IoC)面向切面(AOP)容器框架
  SpringMVC离控制器、模型象、派器及处理程序象角色种离让更容易进行定制
  MyBatis支持普通SQL查询存储程高级映射优秀持久层框架
  断点设定eclipse要点面我设定几断点再面三窗口用调试代码eclipse类似 调试用快捷键 F9 resume programe 恢复程序 Alt F10 show execution point 显示执行断点 F8 Step Over

最新文章

随便看看