import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.io.*;
import javax.naming.*;
import javax.sql.*;
public class Applet1 extends Applet
implements MouseListener, KeyListener ,ActionListener{
String id;
private TextArea textArea1;
private Button do_Button ;
private Button reDo_Button ;
private Button upLoad_Button ;
private Panel panel;
String title;
Connection conn;
public void mousePressed(MouseEvent e){e.consume();}
public void mouseReleased(MouseEvent e){e.consume();}
public void mouseEntered(MouseEvent e){e.consume();}
public void mouseExited(MouseEvent e){e.consume();}
public void mouseClicked(MouseEvent e){e.consume();}
public void keyPressed(KeyEvent e){e.consume();}
public void keyReleased(KeyEvent e){e.consume();}
public void keyTyped(KeyEvent e){e.consume();}
public Applet1() {
try {
Init();
}
catch(Exception e) {
e.printStackTrace();
}
}
public void Init(){
textArea1 = new TextArea(15, 50);
panel=new Panel();
do_Button =new Button("做题");
reDo_Button =new Button("重做");
upLoad_Button =new Button("上传");
panel.add(do_Button);
panel.add(reDo_Button);
panel.add(upLoad_Button);
this.add(textArea1,BorderLayout.NORTH );
this.add(panel,BorderLayout.CENTER);
textArea1.addMouseListener(this);
textArea1.addKeyListener(this);
do_Button.addActionListener(this);
reDo_Button.addActionListener(this);
upLoad_Button.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==do_Button){
doButton();
}
if(e.getSource()==reDo_Button){
reDoButton();
}
if(e.getSource()==upLoad_Button){
upLoadButton();
}
}
public Connection dataBaseConnection() {
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://192.192.2.15:1433;DatabaseName=etest","sa","12345");
}catch(Exception e){
e.getMessage();
e.printStackTrace();
}
return conn;
}
/* public Connection dataBaseConnection() {
try{
Context ctx = new InitialContext();
DataSource ds =
(DataSource)ctx.lookup(
"java:comp/env/jdbc/SqlDB");
conn = ds.getConnection();
}catch(Exception e){
e.getMessage();
}
return conn;
}
*/
public void start(){
id=getParameter("id");
download();
}
private void download(){
try{
Connection conn=dataBaseConnection();
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from word";
ResultSet rs=stmt.executeQuery(sql);
rs.absolute(4);
String title = rs.getString("QUESTION_TITLE1");
textArea1.setText(title);
/*
download the word-document form database to localhost
*/
InputStream inStream=rs.getBinaryStream("QUESTION_CONTEN1");
FileOutputStream fs=new FileOutputStream( "c:\\word.doc");
byte[] buffer =new byte[1444];
int length;
int byteread=0;
while ((byteread=inStream.read(buffer))!=-1){
fs.write(buffer,0,byteread);
}
fs.close();
conn.close();
}catch(SQLException e){
e.getMessage();
e.printStackTrace();
}catch(IOException e){
e.getMessage();
e.printStackTrace();
}
}
private void doButton(){
String path="c:\\word.doc";
try{
Runtime.getRuntime().exec("cmd /c start winword \"" +path+"\"");
}catch(IOException e){
System.err.println("ioexception starting process");
}
}
private void reDoButton(){
download();
doButton();
}
private void upLoadButton(){
try{
Connection conn=dataBaseConnection();
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from students where ID='"+id+"'";
ResultSet rs=stmt.executeQuery(sql);
rs.next();
File file=new File("c:\\word.doc");
FileInputStream fis=new FileInputStream( file);
rs.updateBinaryStream("WORD",fis,(int)file.length());
rs.updateRow();
fis.close();
conn.close();
textArea1.setText("上传成功");
}catch(SQLException e){
e.getMessage();
e.printStackTrace();
}catch(IOException e){
e.getMessage();
e.printStackTrace();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
JAVA在线考试管理系统(源代码+论文+开题报告+外文翻译+英文文献+答辩PPT)

共134个文件
gif:50个
jsp:16个
htm:12个


JAVA在线考试管理系统(源代码+论文+开题报告+外文翻译+英文文献+答辩)
资源推荐
资源详情
资源评论



















收起资源包目录





































































































共 134 条
- 1
- 2
资源评论

- Chackca2019-04-222004年的资源....
Charliexin新
- 粉丝: 3
- 资源: 3

上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制
