mysql ,sqlserver 增加Oracle生成javabean
1.BeanRobot.java 代码
package dbRobot; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.sql.Statement; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import javax.swing.DefaultCellEditor; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; public class BeanRobot extends JFrame { private static final long serialVersionUID = 1L; private JTextField ipFiled; private JTextField dbFiled; private JTextField dbNameFiled; private JTextField tabField; private JTextField packField; private JTextField catField; private JCheckBox checkBox; private JTextField userField; private JTextField pwdField; private JComboBox dbBox; DbUtil dbutil = new DbUtil() ; BeanUtil butil = new BeanUtil(); JLabel labelInfo ; private JTable jtable; private MyTableModel tableModel ; HashMap dbInfoMap; String[] titles = {"选择","表格名称"} ; //配置文件信息 Map<String,HashMap<String,String>> dbMap; public BeanRobot() { setTitle("数据库生成javabean小工具"); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(100, 100, 544, 374); JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.CENTER); panel.setLayout(null); JLabel lblIp = new JLabel("IP:"); lblIp.setBounds(110, 13, 30, 15); panel.add(lblIp); ipFiled = new JTextField(); ipFiled.setText("localhost"); ipFiled.setBounds(146, 10, 147, 21); panel.add(ipFiled); ipFiled.setColumns(10); JLabel label = new JLabel("数据库:"); label.setBounds(80, 41, 54, 15); panel.add(label); // String dbStyles[] = { }; // dbBox = new JComboBox(dbStyles); dbBox = new JComboBox(); dbBox.setBounds(146, 39, 147, 21); dbBox.setVisible(true); dbBox.setMaximumRowCount(3); panel.add(dbBox); JLabel dbNamelabel = new JLabel("数据库名:"); dbNamelabel.setBounds(70, 67, 60, 20); panel.add(dbNamelabel); dbNameFiled = new JTextField(); dbNameFiled.setBounds(146, 68, 147, 21); dbNameFiled.setText("test"); panel.add(dbNameFiled); dbNameFiled.setColumns(10); JLabel userLabel = new JLabel("用户名:"); userLabel.setBounds(80, 98, 54, 15); panel.add(userLabel); userField = new JTextField(); userField.setText("root"); userField.setBounds(145, 97, 148, 21); panel.add(userField); userField.setColumns(10); JLabel pwdLabel = new JLabel("密码:"); pwdLabel.setBounds(95, 129, 54, 15); panel.add(pwdLabel); pwdField = new JTextField(); pwdField.setText("root"); pwdField.setBounds(145, 126, 147, 21); panel.add(pwdField); pwdField.setColumns(10); JLabel packLabel = new JLabel("包名:"); packLabel.setBounds(95, 160, 54, 15); panel.add(packLabel); packField = new JTextField(); packField.setText(""); packField.setBounds(146, 155, 147, 21); panel.add(packField); packField.setColumns(10); JLabel catlogLabel = new JLabel("输出目录:"); catlogLabel.setBounds(70, 193, 65, 15); panel.add(catlogLabel); catField = new JTextField(); catField.setBounds(146, 190, 147, 21); panel.add(catField); catField.setColumns(10); checkBox = new JCheckBox("生成包结构目录"); checkBox.setSelected(true); checkBox.setBounds(145, 220, 147, 23); panel.add(checkBox); JLabel mustdbLabel = new JLabel("* 选择数据库"); mustdbLabel.setForeground(Color.RED); mustdbLabel.setBounds(303, 39, 176, 15); panel.add(mustdbLabel); JLabel mustIPLabel = new JLabel("* IP地址及端口号"); mustIPLabel.setForeground(Color.RED); mustIPLabel.setBounds(303, 13, 176, 15); panel.add(mustIPLabel); JLabel mustPacklabel = new JLabel("* 包结构"); mustPacklabel.setForeground(Color.RED); mustPacklabel.setBounds(303, 155, 79, 15); panel.add(mustPacklabel); JLabel catlabel = new JLabel("默认D:// ;注意格式"); catlabel.setForeground(Color.RED); catlabel.setBounds(303, 193, 179, 15); panel.add(catlabel); JButton button = new JButton("查询"); // 按钮增加动作执行go()方法 button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { go(); } }); button.setBounds(145, 267, 93, 23); panel.add(button); JButton crButton = new JButton("生成Bean"); // 按钮增加动作执行go()方法 crButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { create(); } }); crButton.setBounds(280, 267, 93, 23); panel.add(crButton); // 增加关闭事件监听,关闭相关操作 this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { super.windowClosing(e); close(); System.exit(0); } }); //设置表格 Object[][] tableData = {}; tableModel = new MyTableModel(tableData,titles); jtable = new JTable(this.tableModel) ; TableColumn column=jtable.getColumnModel().getColumn(0); column.setPreferredWidth(30); //设置第一列的宽度30 JScrollPane scr = new JScrollPane(this.jtable) ; scr.setBounds(430, 10, 200, 290); panel.add(scr); //添加标格监听事件 jtable.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ int row=jtable.getSelectedRow(); if(jtable.getSelectedColumn()==0)//如果是第一列的单元格,则返回,不响应点击 return; //列响应操作 } }); //显示操作信息label labelInfo = new JLabel(""); labelInfo.setForeground(Color.RED); labelInfo.setBounds(20, 317, 600, 60); panel.add(labelInfo); //初始化配置信息和数据库下拉列表 dbMap = dbutil.getDbConfigMap(); for(String key : dbMap.keySet()){ this.getDbBox().addItem(key); } } public static void main(String[] args) { // TODO Auto-generated method stub // 创建对象 BeanRobot dtb = new BeanRobot(); // 设置可见 dtb.setVisible(true); // 点击X关闭窗口 dtb.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 调用设置居中显示 dtb.setSizeAndCentralizeMe(680, 440); } // 设置居中 private void setSizeAndCentralizeMe(int width, int height) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setSize(width, height); this.setLocation(screenSize.width / 2 - width / 2, screenSize.height / 2 - height / 2); } public void create(){ String sucessName = ""; this.getLabelInfo().setText(""); initInfo(); //是否勾选生成目录标识 boolean createPackage = this.getCheckBox().getSelectedObjects() != null; //判断目录是否存在 if (dbInfoMap.get("catName") != null ) { if(dbInfoMap.get("catName").toString().equals("")){ dbInfoMap.put("catName", "D://"); } if((new File(dbInfoMap.get("catName").toString()).isDirectory())!=true){ this.getLabelInfo().setText("目录不存在,请重新输入"); }else{ if(createPackage){ if (dbInfoMap.get("packName") != null && !dbInfoMap.get("packName").toString().equals("")) { String catPack = dbInfoMap.get("catName").toString()+dbInfoMap.get("packName").toString(); catPack = catPack.replace(".", "/"); new File(catPack).mkdirs(); dbInfoMap.put("catName", catPack); } //勾选 int rowCount = this.jtable.getRowCount(); for(int i = 0 ; i< rowCount ; i++){ if(this.jtable.getValueAt(i,0).toString().equals("true")){ String tabName = this.jtable.getValueAt(i,1).toString(); List<Map<String, String>> tabFileds = dbutil.getColumnNames(dbInfoMap, tabName); butil.createBean(tabName, tabFileds,dbInfoMap); sucessName+=tabName+","; } } }else{ int rowCount = this.jtable.getRowCount(); for(int i = 0 ; i< rowCount ; i++){ if(this.jtable.getValueAt(i,0).toString().equals("true")){ String tabName = this.jtable.getValueAt(i,1).toString(); List<Map<String, String>> tabFileds = dbutil.getColumnNames(dbInfoMap, tabName); butil.createBean(tabName, tabFileds,dbInfoMap); sucessName+=tabName+","; } } } this.getLabelInfo().setText("表"+sucessName+"生成成功"); } } } public void go() { this.getLabelInfo().setText(""); initInfo(); String selTableStr = dbInfoMap.get("showTable").toString(); //获取表名 List<String> tableList = dbutil.getTableNames(dbInfoMap,dbInfoMap.get("dbName").toString()); if(tableList == null){ int rowCount = this.getTableModel().getRowCount(); int delInd = 0; while(delInd < rowCount){ this.getTableModel().removeRow(0); delInd++; } this.getLabelInfo().setText("数据库连接异常"); }else{ int rowCount = this.getTableModel().getRowCount(); int delInd = 0; while(delInd < rowCount){ this.getTableModel().removeRow(0); delInd++; } for(String tName : tableList){ Object[] rowData = {new Boolean(false),tName}; this.getTableModel().addRow(rowData); } } } public void initInfo(){ //读取配置文件数据库配置 String user = this.getUserField().getText(); String pass = this.getPwdField().getText(); String ip = this.getIpFiled().getText(); String database = this.getDbNameFiled().getText(); String dbName = this.getDbBox().getSelectedItem().toString(); String packName =this.getPackField().getText(); String catName =this.getCatField().getText(); //处理界面数据 dbInfoMap = new HashMap(); dbInfoMap = dbMap.get(dbName); dbInfoMap.put("userName", user); dbInfoMap.put("userpwd", pass); dbInfoMap.put("jdbc", dbMap.get(dbName).get("JdbcURL")+ip+dbMap.get(dbName).get("dbStr")+database); dbInfoMap.put("driver", dbMap.get(dbName).get("driverClassName")); dbInfoMap.put("dbName", database); dbInfoMap.put("packName", packName); dbInfoMap.put("catName", catName); //Edit By HuangJun 2014-07-07 System.out.println(dbInfoMap); /* * MYSQL * dataSource.driverClassName=com.mysql.jdbc.Driver * dataSource.url=jdbc:mysql://192.168.12.55/fzrating?characterEncoding=utf8 * dataSource.username= fzratingtest * dataSource.password= fzratingtest * {userpwd=fzratingtest, dbName=fzrating, JdbcURL=jdbc:mysql://, catName=f:\, userName=fzratingtest, driverClassName=com.mysql.jdbc.Driver, driver=com.mysql.jdbc.Driver, dbStr=/, showTable=select table_name from information_schema.tables where table_schema = '%', packName=davaDemo, showColumns=show columns from %, jdbc=jdbc:mysql://192.168.12.55:3306/fzrating} */ /* * SQlServer * dataSource.driverClassName=net.sourceforge.jtds.jdbc.Driver * dataSource.url=jdbc:jtds:sqlserver://192.168.12.54:1433/FZ_DEV * dataSource.username= fz_dev * dataSource.password= fz_dev * {userpwd=fz_dev, dbName=fz_dev, JdbcURL=jdbc:sqlserver://, catName=f:\, userName=fz_dev, driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver, driver=com.microsoft.sqlserver.jdbc.SQLServerDriver, dbStr=;databaseName=, showTable=select Name from sysobjects where xtype='u' and status>=0, packName=javaDemo, showColumns=select column_name,data_type from information_schema.columns where table_name = '%', jdbc=jdbc:sqlserver://192.168.12.54:1433;databaseName=fz_dev} */ /* Oracle * dataSourceforSe.driverClassName=oracle.jdbc.driver.OracleDriver * dataSourceforSe.url=jdbc:oracle:thin:@192.168.12.230:1521:demo230 * dataSourceforSe.username=ccxe * dataSourceforSe.password=ccxe * {userpwd=ccxe, dbName=demo230, JdbcURL=jdbc:oracle:thin:@, catName=f:\, userName=ccxe, driverClassName=oracle.jdbc.driver.OracleDriver, driver=oracle.jdbc.driver.OracleDriver, dbStr=:, showTable=SELECT TABLE_NAME FROM USER_TABLES, packName=javaDemo, showColumns=select table_name from dba_tables where owner='CCXE', jdbc=jdbc:oracle:thin:@192.168.12.230:1521:demo230} */ } private void close() { System.out.println("关闭事件"); } public JTextField getIpFiled() { return ipFiled; } public void setIpFiled(JTextField ipFiled) { this.ipFiled = ipFiled; } public JTextField getDbFiled() { return dbFiled; } public void setDbFiled(JTextField dbFiled) { this.dbFiled = dbFiled; } public JTextField getTabField() { return tabField; } public void setTabField(JTextField tabField) { this.tabField = tabField; } public JTextField getPackField() { return packField; } public void setPackField(JTextField packField) { this.packField = packField; } public JTextField getCatField() { return catField; } public void setCatField(JTextField catField) { this.catField = catField; } public JCheckBox getCheckBox() { return checkBox; } public void setCheckBox(JCheckBox checkBox) { this.checkBox = checkBox; } public JTextField getUserField() { return userField; } public void setUserField(JTextField userField) { this.userField = userField; } public JTextField getPwdField() { return pwdField; } public void setPwdField(JTextField pwdField) { this.pwdField = pwdField; } public JTextField getDbNameFiled() { return dbNameFiled; } public void setDbNameFiled(JTextField dbNameFiled) { this.dbNameFiled = dbNameFiled; } public JComboBox getDbBox() { return dbBox; } public void setDbBox(JComboBox dbBox) { this.dbBox = dbBox; } public JLabel getLabelInfo() { return labelInfo; } public void setLabelInfo(JLabel labelInfo) { this.labelInfo = labelInfo; } public JTable getJtable() { return jtable; } public void setJtable(JTable jtable) { this.jtable = jtable; } public MyTableModel getTableModel() { return tableModel; } public void setTableModel(MyTableModel tableModel) { this.tableModel = tableModel; } class MyTableModel extends DefaultTableModel{ public MyTableModel(Object[][] data,String[] columns) { super(data,columns); } public boolean isCellEditable(int row,int column){ //设置Table单元格是否可编辑 if(column==0)return true; return false; } public Class<?> getColumnClass(int columnIndex) { if(columnIndex==0) { return Boolean.class; } return Object.class; } } }
2.BeanUtil.java代码
package dbRobot; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class BeanUtil { public BeanUtil() { // TODO Auto-generated constructor stub } //创建JavaBean文件 public String createBean(String tbName, List<Map<String, String>> collist, Map<String, String> infoMap) { StringBuilder fields = new StringBuilder(); StringBuilder methods = new StringBuilder(); StringBuilder classInfo = new StringBuilder("\t/**\r\n\t*"); for (Map<String, String> colmap : collist) { String field = colmap.get("filed").toString(); String type = typeTrans(colmap.get("type").toString()); fields.append(getFieldStr(field, type)); methods.append(getMethodStr(field, type)); } classInfo.append("\t*@author yangsj"); classInfo.append("\r\n\t*/\r\n\r\n"); classInfo.append("\tpublic class ").append(upperFirestChar(tbName)) .append("{\r\n"); classInfo.append(fields); classInfo.append("\r\n"); classInfo.append(methods); classInfo.append("\r\n"); classInfo.append("}"); File file = new File(infoMap.get("catName"), upperFirestChar(tbName) + ".java"); try { FileWriter fw = new FileWriter(file); if (infoMap.get("packName") == null || infoMap.get("packName").toString().equals("")) { } else { String packageinfo = "package " + infoMap.get("packName").toString() + ";\r\n\r\n"; fw.write(packageinfo); } fw.write(classInfo.toString()); fw.flush(); fw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } //数据库字段类型与JAVA类型转换 public String typeTrans(String type) { if (type.contains("tinyint")) { return "boolean"; } else if (type.contains("int")) { return "int"; } else if (type.contains("datetime")) { return "Date"; } else if (type.contains("BIGINT")) { return "Long"; } else if (type.contains("varchar") || type.contains("date") || type.contains("time") || type.contains("timestamp") || type.contains("text") || type.contains("enum") || type.contains("set")) { return "String"; } else if (type.contains("binary") || type.contains("blob")) { return "byte[]"; } else { return "String"; } } //获取方法字符串 private String getMethodStr(String field, String type) { StringBuilder get = new StringBuilder("\tpublic "); get.append(type).append(" "); if (type.equals("boolean")) { get.append(field); } else { get.append("get"); get.append(upperFirestChar(field)); } get.append("(){").append("\r\n\t\treturn this.").append(field) .append(";\r\n\t}\r\n"); StringBuilder set = new StringBuilder("\tpublic void "); if (type.equals("boolean")) { set.append(field); } else { set.append("set"); set.append(upperFirestChar(field)); } set.append("(").append(type).append(" ").append(field) .append("){\r\n\t\tthis.").append(field).append("=") .append(field).append(";\r\n\t}\r\n"); get.append(set); return get.toString(); } //首字母大写 public String upperFirestChar(String src) { return src.substring(0, 1).toUpperCase().concat(src.substring(1)); } //获取字段 private String getFieldStr(String field, String type) { StringBuilder sb = new StringBuilder(); sb.append("\t").append("private ").append(type).append(" ") .append(field).append(";"); sb.append("\r\n"); return sb.toString(); } }
3.DbUtil.java
package dbRobot; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.sql.DataSource; public class DbUtil { public Statement st ; public DbUtil(){ } /** * paraMap参数 * driverClassName 驱动 * JdbcURL jdbc 该字符串为: config.ini 的JdbcURL+IP地址(含端口号)+dbStr+数据库名称 * userName 数据库名称 * userpwd 数据库密码 * */ public Statement getStatement(Map<String,String> paraMap) { //加载数据库驱动 try { Class.forName(paraMap.get("driver")); Connection conn = DriverManager.getConnection(paraMap.get("jdbc"), paraMap.get("userName"), paraMap.get("userpwd")); if(!conn.isClosed()){ }else{ return null; } // statement用来执行SQL语句 Statement statement = conn.createStatement(); return statement; // 要执行的SQL语句 } catch (Exception e) { // TODO Auto-generated catch block return null; } } //读取数据库表信息 public List<String> getTableNames(Map<String,String> dbInfoMap,String dbName){ List<String> tableList = new ArrayList<String>(); //存储表名 try { st = this.getStatement(dbInfoMap); if(st == null){ return null; } //替换数据库名字占位符 String selTableSql = dbInfoMap.get("showTable").toString().replace("%", dbName); ResultSet tabRs = st.executeQuery(selTableSql); //保存表名 while(tabRs.next()){ tableList.add(tabRs.getString(1)); } }catch (SQLException e) { // TODO Auto-generated catch block return null; } return tableList; } //读取表字段信息 public List<Map<String,String>> getColumnNames(Map<String,String> dbInfoMap,String tabName){ List<Map<String,String>> colList = new ArrayList<Map<String,String>>(); //存储字段信息 try { st = this.getStatement(dbInfoMap); if(st == null){ return null; } //替换表名占位符 String selColumnSql = dbInfoMap.get("showColumns").toString().replace("%", tabName); ResultSet columnRs = st.executeQuery(selColumnSql); while(columnRs.next()){ Map<String,String> colMap = new HashMap<String,String>(); colMap.put("filed", columnRs.getString(1)); colMap.put("type", columnRs.getString(2)); colList.add(colMap); } }catch (SQLException e) { // TODO Auto-generated catch block return null; } return colList; } // 读取配置 public Map<String, HashMap<String, String>> getDbConfigMap() { Map<String, HashMap<String, String>> sectionsMap = new HashMap<String, HashMap<String, String>>(); HashMap<String, String> itemsMap = new HashMap<String, String>(); String currentSection = ""; BufferedReader reader = null; try { //读取当前文件路径下的ini文件 System.out.println(this.getClass().getResourceAsStream("config.ini")); InputStream configStream = this.getClass().getResourceAsStream("config.ini"); reader = new BufferedReader(new InputStreamReader(configStream, "gbk")); String line = null; while ((line = reader.readLine()) != null) { line = line.trim(); if ("".equals(line)) continue; if (line.startsWith("[") && line.endsWith("]")) { itemsMap = new HashMap<String, String>(); currentSection = line.substring(1, line.length() - 1); sectionsMap.put(currentSection, itemsMap); currentSection = ""; }else{ int index = line.indexOf("="); if (index != -1) { String key = line.substring(0, index); String value = line.substring(index + 1, line.length()); itemsMap.put(key, value.trim()); } } } reader.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally { if (reader != null) { try { reader.close(); } catch (IOException e1) { e1.printStackTrace(); } } return sectionsMap; } } }
4.数据库连接字符串
/* * MYSQL * dataSource.driverClassName=com.mysql.jdbc.Driver * dataSource.url=jdbc:mysql://192.168.12.55/fzrating?characterEncoding=utf8 * dataSource.username= fzratingtest * dataSource.password= fzratingtest * {userpwd=fzratingtest, dbName=fzrating, JdbcURL=jdbc:mysql://, catName=f:\, userName=fzratingtest, driverClassName=com.mysql.jdbc.Driver, driver=com.mysql.jdbc.Driver, dbStr=/, showTable=select table_name from information_schema.tables where table_schema = '%', packName=davaDemo, showColumns=show columns from %, jdbc=jdbc:mysql://192.168.12.55:3306/fzrating} */ /* * SQlServer * dataSource.driverClassName=net.sourceforge.jtds.jdbc.Driver * dataSource.url=jdbc:jtds:sqlserver://192.168.12.54:1433/FZ_DEV * dataSource.username= fz_dev * dataSource.password= fz_dev * {userpwd=fz_dev, dbName=fz_dev, JdbcURL=jdbc:sqlserver://, catName=f:\, userName=fz_dev, driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver, driver=com.microsoft.sqlserver.jdbc.SQLServerDriver, dbStr=;databaseName=, showTable=select Name from sysobjects where xtype='u' and status>=0, packName=javaDemo, showColumns=select column_name,data_type from information_schema.columns where table_name = '%', jdbc=jdbc:sqlserver://192.168.12.54:1433;databaseName=fz_dev} */ /* Oracle * dataSourceforSe.driverClassName=oracle.jdbc.driver.OracleDriver * dataSourceforSe.url=jdbc:oracle:thin:@192.168.12.230:1521:demo230 * dataSourceforSe.username=ccxe * dataSourceforSe.password=ccxe * {userpwd=ccxe, dbName=demo230, JdbcURL=jdbc:oracle:thin:@, catName=f:\, userName=ccxe, driverClassName=oracle.jdbc.driver.OracleDriver, driver=oracle.jdbc.driver.OracleDriver, dbStr=:, showTable=SELECT TABLE_NAME FROM USER_TABLES, packName=javaDemo, showColumns=select table_name from dba_tables where owner='CCXE', jdbc=jdbc:oracle:thin:@192.168.12.230:1521:demo230} */
5.config.ini 数据库配置
[MySQL] driverClassName=com.mysql.jdbc.Driver JdbcURL=jdbc:mysql:// dbStr=/ showTable=select table_name from information_schema.tables where table_schema = '%' showColumns=show columns from % [SQL_Server] driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver JdbcURL=jdbc:sqlserver:// dbStr=;databaseName= showTable=select Name from sysobjects where xtype='u' and status>=0 showColumns= select column_name,data_type from information_schema.columns where table_name = '%' [ORACLE] driverClassName=oracle.jdbc.driver.OracleDriver JdbcURL=jdbc:oracle:thin:@ dbStr=: showTable=SELECT TABLE_NAME FROM USER_TABLES showColumns= select column_name,data_type from user_tab_columns where Table_Name='%'
6.截图
MySQL.jpg
SQL_Server.jpg
Oracle.jpg
参考了:
http://www.oschina.net/code/snippet_128886_26726
http://marsvaadin.iteye.com/blog/1465592 相关内容。
相关推荐
1. **多数据库支持**:工具支持主流的关系型数据库,如MySQL、Oracle和SQL Server。这意味着不论你使用哪种数据库,都可以通过该工具快速生成与数据库表对应的JavaBean对象。数据库连接配置的灵活性使得开发者可以...
于是一怒之下,自己动手丰衣足食,就自己用Swing写了一个通过数据库的表生成JavaBean的工具,支持MySQL、Oracle、SQLServce,完美支持JPA注解,可以同时生成Entity和DTO,可以自动去除表前缀,并支持去除多个前缀,...
下载了绝对不后悔,100%好用,支持Mysql Oracle SQL Server ,PostgreSQl.等数据库 还有各种集成的小工具 表名互转驼峰,,,,Json.XML 字符串格式化..JSon与XMl互转,String字符串拼接等功能
对于Oracle数据库,其JDBC驱动是`oracle.jdbc.driver.OracleDriver`,而SQL Server的JDBC驱动是`com.microsoft.sqlserver.jdbc.SQLServerDriver`。注册驱动和获取连接的代码会有所不同,但基本流程与MySQL类似。 在...
2. **数据库支持**:列出工具所支持的数据库类型,如MySQL、Oracle、SQL Server等,以及如何配置不同数据库的连接。 3. **自动生成JavaBean**:说明如何通过选择数据库表来生成对应的JavaBean类,包括字段映射、...
系统中的数据存储通常依赖于SQL(结构化查询语言)数据库,如MySQL、Oracle或SQL Server。SQL用于创建、查询、更新和删除数据库中的数据。在这个案例中,开发者可能会设计一个名为“Student”的表,包含学号、姓名、...
此外,TableGo支持多种数据库系统,如MySQL、Oracle、SQL Server等,以及多平台运行,如Windows、Linux和Mac OS。 使用TableGo,开发者只需精心设计数据库并添加备注,然后通过自定义模板生成所需的任何编程语言...
该工具支持多种数据库系统,包括MySQL、Oracle和SQL Server,这些都是广泛应用于企业级开发的主流数据库。 MySQL是一款开源、免费的关系型数据库管理系统,以其轻量级、高效率和易于管理而受到开发者喜爱。Oracle则...
1. **数据库连接**:支持多种常见的数据库类型,如MySQL、Oracle、SQL Server等,允许用户输入数据库连接信息,建立与数据库的连接。 2. **表结构解析**:读取数据库中的表结构,包括表名、字段名、字段类型、主键等...
实际应用中,这样的工具可以扩展以支持更复杂的SQL特性,如索引、外键、触发器等,同时也可以适应不同的数据库方言,如MySQL、Oracle、SQL Server等。 总的来说,这个项目展示了如何将数据库设计与面向对象编程相...
4. **扩展数据库支持**:TableGo不仅支持常见的MySQL、Oracle、SQL Server等,还增加了对武汉达梦、人大金仓V8、神舟通用、南大通用等国产数据库的扩展支持,扩大了适用范围。 5. **项目工程生成**:工具新增了生成...
使用时,用户可能需要提供数据库连接信息,如数据库类型(MySQL, Oracle, SQL Server等)、数据库URL、用户名和密码,然后选择要转换的表,工具就会自动生成相应的JavaBean类,这些类包含了表中的字段及其对应的...
JSP+Oracle数据库开发与实例 张晓东,高鉴伟 清华大学出版社 ... 本书适用于使用JSP和Oracle开发动态网站的技术人员以及对相关技术感兴趣的读者,同时可以供使用SQL Server、MySQL等数据库开发网站的读者参考。
JDBC 提供了一种统一的接口,用于连接各种类型的数据库,例如 MySQL、Oracle、SQL Server 等。 在 JavaBean 中连接数据库的步骤 在 JavaBean 中连接数据库需要遵循以下步骤: 1. 创建 JavaBean:首先,需要创建一...
2. 专业性:支持多种数据库类型,如MySQL、Oracle、SQL Server等,并且能够处理复杂的表关系,如外键、联合主键等。 3. 完整性:不仅生成简单的getter和setter方法,还可能包括构造函数、equals()、hashCode()、...
- 工具可能使用JDBC(Java Database Connectivity)API来连接到不同类型的数据库,如MYSQL、ORACLE和SQLSERVER。 - JDBC提供了统一的接口,使得Java程序可以与多种数据库进行交互,而无需关心具体的数据库方言。 ...
数据库通常是MySQL或Oracle等关系型数据库管理系统,存储着航班信息、用户信息、预订记录等关键数据。 JSP技术的核心特性包括: 1. **声明式编程**:JSP页面可以包含HTML、XML或其他标记语言,开发者可以在其中...