Jdbc.odbc.JdbcOdbcDriver----------------->Please Help Me!
//
//
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class My_test extends JFrame
{
//**********************************************************变量申明************************************************************//
Container ctp = getContentPane();
JPanel pa_btn = new JPanel(),
pa_tbl = new JPanel(),
pa_scrll = new JPanel(),
pa_statu = new JPanel();
ImageIcon ico_add = new ImageIcon("add.gif"),
ico_add_up = new ImageIcon("add_up.gif"),
ico_add_down = new ImageIcon("add_down.gif");
ImageIcon ico_del = new ImageIcon("del.gif"),
ico_del_up = new ImageIcon("del_up.gif"),
ico_del_down = new ImageIcon("del_down.gif");
JButton btn_add = new JButton("add",ico_add),
btn_del = new JButton("del",ico_del);
JLabel lb_statu = new JLabel("hello");
JTable tbl ;
String url = "jdbc:odbc:My_test";
String[] title = {"姓名","年龄","OICQ","Email","电话","详细地址"};
String[][] content = {{"","","","","",""},
{"","","","","",""},
{"","","","","",""},
{"","","","","",""},
{"","","","","",""},
{"","","","","",""},
{"","","","","",""}, {"","","","","",""}};
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
//----------------------------初始化组件----------------------------//
public My_test ()
{
ctp.setLayout(new BorderLayout());
ctp.add("North",pa_btn);
ctp.add("East",pa_scrll);
ctp.add("South",pa_statu);
ctp.add("Center",pa_tbl);
pa_btn.setLayout(new FlowLayout());
pa_btn.add(btn_add);
pa_btn.add(btn_del);
pa_tbl.setLayout(new BorderLayout());
JTable tbl = new JTable(content,title);
pa_tbl.add("Center",tbl);
pa_statu.setLayout(new BorderLayout());
pa_statu.add("Center",lb_statu);
JScrollPane sp = new JScrollPane(tbl,v,h);
pa_scrll.setLayout(new FlowLayout());
pa_scrll.add(sp);
btn_add.setRolloverIcon(ico_add_up);
btn_add.setPressedIcon(ico_add_down);
btn_del.setRolloverIcon(ico_del_up);
btn_del.setPressedIcon(ico_del_down);
setSize(500,300);
setTitle("My_test");
setVisible(true);
addWindowListener(new MywindowListener());
}
//############ 事件处理 ###################### //
class MywindowListener extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
dispose();
System.exit(0);
}
}
class myActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Object source=e.getSource();
if (source==btn_add)
{
}
else
{
}
}
}
//=== 自定义函数 ==============================//
//================== 数据库查询 =================//
class sql
{
public void sql_do ()
{
String url = "jdbc:ocbc:My_test";
try
{
Class.forName("sun.jcbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(url,"","");
String sql = "SELECT * FROM My_test";
Statement state = conn.createStatement();
ResultSet content = state.executeQuery(sql);
conn.close();
}
catch (Exception ee)
{
lb_statu.setText("读取数据库出错");
}
}
};
//====================== 数据库 完 =================//
//================================= 主函数 =============//
public static void main(String args[])
{
My_test test =new My_test();
}
};
问题:::::::
用javac 编译没有出现问题,用java运行,就是没有结果,表格里面不能显示数据库的记录,是不是我的数据库部分有问题?
如果是我的数据库查询部分有问题,请帮我写一下代码,因为我是初学者,这里一直没有弄明白,多谢指教!!!