帮忙看下,这段代码的错误在哪里?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.text.*;
import java.text.SimpleDateFormat;
public class NewFrame extends JFrame
{
JLabel lab1=new JLabel("设置日期:");
JLabel lab2=new JLabel("设置时间:");
JLabel lab3=new JLabel(" 标题:");
JTextField tf1=new JTextField();
JTextField tf2=new JTextField();
JTextField tf3=new JTextField();
JTextArea ta=new JTextArea();
JButton btnQue=new JButton("确定");
JButton btnCancle=new JButton("取消");
JLabel lab4=new JLabel(" shijian");
public NewFrame()
{
super();
Container conn=getContentPane();
conn.setBounds(0,0,450,450);
lab1.setFont(new Font("宋体",Font.BOLD,15));
lab2.setFont(new Font("宋体",Font.BOLD,15));
lab3.setFont(new Font("宋体",Font.BOLD,15));
lab1.setBounds(20,20,90,20);
lab2.setBounds(20,60,90,20);
lab3.setBounds(20,100,90,20);
tf1.setBounds(100,20,200,20);
tf2.setBounds(100,60,200,20);
tf3.setBounds(100,100,200,20);
conn.add(lab1);
conn.add(tf1);
conn.add(lab2);
conn.add(tf2);
conn.add(lab3);
conn.add(tf3);
JScrollPane scroll=new JScrollPane(ta);
scroll.setBounds(20,150,400,200);
conn.add(scroll);
btnQue.setBounds(20,400,90,20);
ButtonHandler handler = new ButtonHandler();
btnQue.addActionListener(handler);
conn.add(btnQue);
btnCancle.setBounds(130,400,90,20);
conn.add(btnCancle);
lab4.setBounds(20,440,20,10);
conn.add(lab4);
SimpleDateFormat dateformatD=new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat dateformatT=new SimpleDateFormat("HH:mm:ss");
Date date=new Date();
String now=(dateformatD.format(date)).toString();
String now1=(dateformatT.format(date)).toString();
tf1.setText(now);
tf2.setText(now1);
btnCancle.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
}
private class ButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e)
{
String sql="";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String source="jdbc:odbc:design";
Connection con=DriverManager.getConnection(source);
Statement stmt=con.createStatement();
tf1.setText(tf1.getText());
tf2.setText(tf2.getText());
tf3.setText(tf3.getText());
sql="INSERT INTO Th1(date,time,lab,thing) VALUES(tf1.getText(),tf2.getText(),tf3.getText(),ta.getText())";
stmt.executeUpdate(sql);
}catch(Exception ew)
{
;
}
}
}
public void rePaint()
{
tf3.setText(" ");
ta.setText(" ");
}
public static void main(String[] args)
{
NewFrame newframe=new NewFrame();
newframe.setVisible(true);
}
}
编译无错,但数据库连接不上,晕死!那个btnQue按钮也点击不了,真想撞死!!!
帮忙!高手!!