If the complete code or suggestion is required to send to zhobekui@eyou.com. Metadata class, can achieve corresponding data table information under Oralce, and generate file SQLMAP files * Currently generated IBATIS from database tables to iBATIS SQLMAP types Main SELECT, INSERT, UPDATE * Because of projects, just temporarily, No development of ResultMap and ParameterMap generation * Practice to develop this tool, graphize it, first listen to you, I hope to communicate with you. * Call the program, just call the getMetadata () method * Database configuration cn / card / mofit / demap-config.xml, * Modify the JDBC.Properties database configuration in the current directory It is possible to use its main class implementation method: package cn.com.mofit.util.jdbc; import java.io.File; import java.io.RIXCEPTION; import java.ioException; import java.io.reader; import java .sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import java.sql.Types; import java. util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Vector; import org.springframework.dao.DataAccessException; import org.springframework.orm.ibatis.SqlMapClientTemplate; import cn.com. mofit.util.spring.orm.ibatis.SqlMapDaoSupportPlus; import com.ibatis.common.resources.Resources; import com.ibatis.sqlmap.client.SqlMapClient; import com.ibatis.sqlmap.engine.builder.xml.XmlSqlMapClientBuilder; / *** * @author Zhou Weikui * 2004-10-15 * @Email: zhobe @DepRecated metadata class, can achieve the corresponding data table information under Oralce, and generate file SQLMAP files * At present, IBATIS can be generated from the database table to the ibatis Sqlmap type. There is mainly SELECT, INSERT, UPDATE * Because the project is too urgent, it is only temporary, there is no development of ResultMap and ParameterMap generation * Practice plan to develop this tool, and graphically, first Listen to you, I hope to communicate with you.
* Call the program, just call the getMetadata () method * Database configuration cn / card / mofit / demap-config.xml, * Modify the JDBC.Properties database configuration in the current directory You can use the path name generated by * / public class rsmetataracle {/ ** filepath sqlmap file, is an absolute path * / private string filepath = "c: /"; / ** maptablename to map the table name * / private string maptablename = "BK_BILL"; // System.getProperty ( "user.dir") "/ config / sqlmap /"; private static SqlMapClientTemplate sqlTemp; static {try {SqlMapDaoSupportPlus sqlsu = new SqlMapDaoSupportPlus (); String resource = "cn / com /mofit/demo/system/dao/maps/sqlMap-config.xml";Reader read; read = Resources.getResourceAsReader (resource); XmlSqlMapClientBuilder xmlBuilder = new XmlSqlMapClientBuilder (); SqlMapClient sqlMap = xmlBuilder.buildSqlMap (read); sqlsu. setSqlMapClient (sqlMap); sqlsu.afterPropertiesSet (); sqlTemp = sqlsu.getSqlMapClientTemplate ();} catch (IOException e1) {e1.printStackTrace ();} catch (Exception e) {e.printStackTrace ();}} private static SqlMapClientTemplate GetsqlmapTempinstance () {return sqltemp;} public void getmetata () T hrows DataAccessException {try {//DaoCommon.startTransaction();SqlMapClientTemplate sqlTemp = RsMetaDataOracle.getSqlMapTempInstance (); // SqlMap sqlMap = DaoCommon.getSqlMap (this); Connection conn = sqlTemp.getDataSource () getConnection ();. Statement stmt = Conn.createStatement (); list list = gettablenames (); for (item t = list.iterator (); it.hasnext () {string element = (String) iter.next (); resultset = stmt.executeQuery (" Select * from " Element); ResultSetMetadata RSMD = rs.getMetadata (); int numberofcolumns = rsmd.getColumnCount ();
IF (Element.startSwith ())) {file file = new file (filepath); if (! file.exists ()) {file.mkdir ();} file = new file (FilePath Element.tolowerCase () ".xml"); string XML = " XML Version = /" 1.0 / "encoding = /" gbk / "?> / n"; XML = " / n"; XML = ("
===================================================== -> "; Result = ("/ n
" "; Result = (" / n
Update ID = / "update" Tablename.tolowercase () "DAO /" parameterclass = / "java.util.hashmap /"> "); Result = (" / n Update " Tablename " / n
Break; default: Break;} result = ("/ n ispropertn") "/ n ispropertyavailable>";} return result;} private void gettype (ResultsetMetadata RSMD, INT I, Hashmap Colmap) throws SQLException {switch (rsmd.getColumnType) {case Types.VARCHAR: colMap.put ( "COLUMNTYPE", rsmd.getColumnTypeName "(" rsmd.getPrecision ")"); break; case 2: colMap.put ( " COLUMNTYPE ", rsmd.getColumnTypeName " ( " rsmd.getPrecision ", " rsmd.getScale ") "); break; default: colMap.put (" COLUMNTYPE ", rsmd.getColumnTypeName); break;}} private List getTableNames () throws DataAccessException {List result = new Vector (); // sqlMap sqlMap = DaoCommon.getSqlMap (this); Connection conn;.. try {conn = getSqlMapTempInstance () getDataSource () getConnection (); DatabaseMetaData dbmd = conn .getMetadata (); ResultSet RS = dbmd.gettabletypes (); string [] type = {"table"}; = dbmd.gettables (null, dbmd.getusername (), "%", types); while (RS. Next ()) {result.add (rs.getstring ("table_name"));}}} catch (sqlexception e) {E.PrintStackTrace ();} Retur n result;} public String getFilePath () {return filePath;} public void setFilePath (String filePath) {this.filePath = filePath;} public String getMapTablename () {return mapTablename;} public void setMapTablename (String mapTablename) {this.mapTablename = maptablename;}} SQL-Config file configuration is: XML version = "1.0" encoding = "GB2312"?>