java实验报告模版.docx

上传人:b****5 文档编号:2780843 上传时间:2022-11-15 格式:DOCX 页数:19 大小:1.70MB
下载 相关 举报
java实验报告模版.docx_第1页
第1页 / 共19页
java实验报告模版.docx_第2页
第2页 / 共19页
java实验报告模版.docx_第3页
第3页 / 共19页
java实验报告模版.docx_第4页
第4页 / 共19页
java实验报告模版.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

java实验报告模版.docx

《java实验报告模版.docx》由会员分享,可在线阅读,更多相关《java实验报告模版.docx(19页珍藏版)》请在冰豆网上搜索。

java实验报告模版.docx

java实验报告模版

 

南京林业大学经济管理学院

2011~2012学年1学期

实验、实习报告

课程名称:

高级程序设计与开发

指导教师:

王磊

 

班级:

姓名:

学号:

 

课程名称:

高级程序设计与开发

实验内容

结合管理信息系统实验课程及管理信息系统课程设计,设计并实现一个管理信息系统

实验时间

32学时

指导教师

王磊

班级

姓名

 

实验要点:

熟悉Java语言开发环境、API、开发技术。

结合实际管理信息系统的开发过程训练Java语言程序开发技术。

 

实验内容:

一:

熟悉java语言开发环境,安装、配置、使用Eclipse,并写出HelloWorld和HelloApplet程序

编写Helloworld!

程序:

 

编写Helloapplet!

程序:

二:

熟悉Java的GUI编程技术,会使用各种控件

(1)绘制图形:

(2)设置字体:

(3)设置颜色:

(4)显示图像:

(5)事件响应:

(6)布局管理器

GridLayout布局管理器

SwingGUI组件

(1)JApplet

(2)JButton

(3)JSlider

三:

掌握一种Java数据库连接方法,并编程实现

(1)sql建立数据库

职工表:

emp(eno,ename,sex,birthday,sal,dno)

部门表:

dept(dno,dname,phone)

创建表:

插入数据:

创建指向sql数据库的数据源

(2)JDBC与数据库连接

显示emp表中第一列:

importjava.sql.*;

publicclassjdbcodbc{

publicstaticvoidmain(String[]args){

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connectioncon=DriverManager.getConnection(

"jdbc:

odbc:

java","sa","sa");

Statementstmt=con.createStatement();

ResultSetrs=stmt.executeQuery("select*fromemp");

while(rs.next())

{System.out.print(rs.getString

(1)+""+

rs.getString

(2)+""+

rs.getString(3)+""+

rs.getDate(4)+""+

rs.getString(5)+""+

rs.getString(6));}

rs.close();

stmt.close();

}catch(Exceptione){

e.printStackTrace();

}

}

}

显示dept表中数据列

四:

结合管理信息系统的系统开发计划和系统详细设计文档,编写代码实现系统。

(1)用户登录界面设计

importjava.awt.*;

importjava.awt.event.*;

importjava.sql.*;

classNewclassextendsFrameimplementsActionListener

{Stringc1,c2;

Labelhead,a,b,blow;

Panell1,l2;

TextFieldt1,t2;

Buttonb1,b2,b3;

Connectioncon;

Statementsql;

ResultSetres;

booleand;

publicstaticvoidmain(Stringargs[])

{Newclasswin=newNewclass("用户登录系统");

win.addWindowListener(

newWindowAdapter()

{publicvoidwindowClosing(WindowEvente){System.exit(0);}

});}

Newclass(Strings)

{setLayout(null);

head=newLabel("用户登录");

a=newLabel("密码:

");

b=newLabel("用户名:

");

b1=newButton("确定");

b2=newButton("取消");

b3=newButton("注册");

blow=newLabel();

t1=newTextField(10);

t2=newTextField(10);

t1.setEchoChar('*');

add(head);

add(b);

add(t2);

add(a);

add(t1);

add(b1);add(b2);add(b3);add(blow);

b1.addActionListener(this);

b3.addActionListener(this);

b2.addActionListener(this);

head.setForeground(Color.blue);

head.setBounds(75,35,80,15);

b.setBounds(20,55,40,15);

t2.setBounds(75,55,100,20);

a.setBounds(20,85,40,15);

t1.setBounds(75,85,100,20);

b1.setBounds(25,115,40,15);

b2.setBounds(83,115,40,15);

b3.setBounds(135,115,40,15);

blow.setBounds(25,134,150,20);

setBounds(100,125,200,160);

setVisible(true);

validate();}

publicvoidactionPerformed(ActionEvente)

{Strings1=t1.getText();

Strings2=t2.getText();

if(s1!

=""&&s2!

=""&&e.getSource()==b3)

{Stringcheck="Insertstuvalues('"+s2+"','"+s1+"')";

try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}

catch(ClassNotFoundExceptionm)

{System.out.println(""+m);}

try{con=DriverManager.getConnection("jdbc:

odbc:

test");

sql=con.createStatement();

sql.executeUpdate(check);

}

catch(SQLExceptionm)

{System.out.print(""+m);

}blow.setText("注册成功!

");};

if(e.getSource()==b1)

{Stringcheck="selectname,pwdfromstuwherename='"+s2+"'andpwd='"+s1+"'";

try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}

catch(ClassNotFoundExceptionm)

{

System.out.println(""+m);

}

try{con=DriverManager.getConnection("jdbc:

odbc:

test");

sql=con.createStatement();

res=sql.executeQuery(check);

d=res.next();

}

catch(SQLExceptionm)

{System.out.print(""+m);

}

if(d==false)

blow.setText("未注册,请注册!

");

if(d!

=false)blow.setText("登录成功");

}

if(e.getSource()==b2){t1.setText("");t2.setText("");}

}}

 

importjava.awt.*;

importjava.awt.event.*;

importjavax.swing.*;

importjava.sql.*;

publicclasslandextendsJFrame

{

JFramejf;

JTextFieldtextname=newJTextField();

JPasswordFieldtextmima=newJPasswordField();

//JLabellabel=newJLabel("学生信息管理系统");

JLabellabelname=newJLabel("用户名");

JLabellabelmima=newJLabel("密码");

JButtonbtenter=newJButton("确定");

JButtonbtcancel=newJButton("清空");

publicland()

{

jf=this;

setTitle("登陆");

Fontf=newFont("新宋体",Font.PLAIN,12);

Containerctn=getContentPane();

ctn.setLayout(null);

labelname.setBounds(45,40,55,20);

labelname.setFont(f);

ctn.add(labelname);

textname.setBounds(95,40,120,20);

ctn.add(textname);

labelmima.setBounds(45,70,45,20);

ctn.add(labelmima);

labelmima.setFont(f);

textmima.setBounds(95,70,120,20);

ctn.add(textmima);

btenter.setBounds(90,110,60,20);

btenter.setFont(f);

ctn.add(btenter);

Monitor_1bt=newMonitor_1();

btenter.addActionListener(bt);

btcancel.setBounds(155,110,60,20);

btcancel.setFont(f);

ctn.add(btcancel);

Monitor_2btc=newMonitor_2();

btcancel.addActionListener(btc);

jf.setResizable(false);

jf.setLocation(400,400);

jf.setSize(300,200);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1