mysqlÊý¾Ý¿âģʽÐÅÏ¢ÌáÈ¡
´Ë³ÌÐòʵÏÖ½«mysqlÊý¾Ý¿âµÄģʽÐÅϢչʾ³öÀ´¡£ÏÂÃæÎÒ¼òÒªµØ˵Ã÷һϡ£
1.Ê÷ÐνṹµÄʵÏÖ¡£
SimplePanel pl=new SimplePanel();
private void buildFrameLayout(){
try{ pane = getContentPane();
//¹Ø±ÕÃæ°å
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//BorderLayout²¼¾Ö¹ÜÀíÆ÷
JPanel panel = new JPanel();
final JScrollPane scrollPane = new JScrollPane();
//panel.setBounds(24, 10, 173, 317);
panel.add(scrollPane);
//³õʼ»¯¸ù½Úµã
DefaultMutableTreeNode root=new DefaultMutableTreeNode(connection.getCatalog());
//»ñµÃ±íÃû
Vector<Object> vector = getTableNames();
DefaultMutableTreeNode menu_accp = null;
for(int i = 0; i < vector.size(); i++){
String strName = (String)vector.get(i);
//³õʼ»¯Ö¦½Úµã
menu_accp = new DefaultMutableTreeNode(strName);
Vector<Object> vectorColumn = getColumnNames(strName);
DefaultMutableTreeNode menu_accp_son = null;
//Ìí¼ÓÖ¦½ÚµãÊý¾Ý
root.add(menu_accp);
for(int j = 0; j < vectorColumn.size(); j++){
//³õʼ»¯Ò¶×Ó½Úµã
menu_accp_son = new DefaultMutableTreeNode((String)vectorColumn.get(j));
//Ìí¼ÓÒ¶×Ó½ÚµãÊý¾Ý
menu_accp.add(menu_accp_son);
}
}
tree = new JTree(root);
TreeSelectionModel model = tree.getSelectionModel();
//Ò»´ÎÖ»ÄÜÑ¡ÔñÒ»¸öÊ÷½Úµã
model.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
//ÏÔʾÊ÷
scrollPane.setViewportView(tree);
pane.add(panel,BorderLayout.WEST);
//×¢²áµã»÷½Úµãʼþ
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree
.getLastSelectedPathComponent();
// ¿ÉÑ¡Óû§¶ÔÏó
Object nodeInfo = node.getUserObject();
if (node.getLevel()==0) {
//¸ù½Úµã²»´¦Àí
} else if (node.getLevel()==1){
//Ö¦½Úµã
pl.getPanel(connection, nodeInfo.toString(),node.getParent().toString(),node.getLevel());
Ïà¹ØÎĵµ£º
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySQLDriverCS;
&nb ......
MysqlÊý¾Ý¿âÌṩÁ½ÖÖÀàÐ͵ÄË÷Òý£¬Èç¹ûûÕýÈ·ÉèÖã¬Ë÷ÒýµÄÀûÓÃЧÂÊ»á´ó´òÕÛ¿ÛÈ´ÍêÈ«²»ÖªÎÊÌâ³öÔÚÕâ¡£
CREATE TABLE test (
id INT NOT NULL,
last_name CHAR(30) NOT NULL,
first_name CHAR(30) NOT NULL,
PRIMARY KEY (id),
INDEX name (last_name,first_name)
);
ÒÔÉÏ´ ......
......
mysql Æ𶯴íÎó½â¾ö°ì·¨- -
Access denied for user ''@'localhost' to d ......