private static final long serialVersionUID = 1L;
public String excute() {
DOBO bo = DOBO.getDOBOByName("do_datasource");
DODataSource dss = DODataSource.getDataSourceByL10n(bo
.getCorrInstance().getValue("l10n"));
String fileName = null;
URL url = DOGlobals.class.getResource("/globals.xml");
String fullFilePath = url.getPath();
String prefix = fullFilePath.substring(0, fullFilePath.toLowerCase()
.indexOf("web-inf"));
if("mysql".equalsIgnoreCase(dss.getDialect())){
fileName = prefix + "/exedo/initsql/mysql.sql";
}else if ("sqlserver".equalsIgnoreCase(dss.getDialect())){
fileName = prefix + "/exedo/initsql/sqlserver2000.sql";
}
else if ("oracle".equalsIgnoreCase(dss.getDialect())){
fileName = prefix + "/exedo/initsql/oracle.sql";
}else if ("gae".equalsIgnoreCase(dss.getDialect())){
fileName = prefix + "/exedo/initsql/gae.sql";
}
else if ("db2".equalsIgnoreCase(dss.getDialect())){
fileName = prefix + "/exedo/initsql/db2.sql";
}
else if ("h2".equalsIgnoreCase(dss.getDialect())){
fileName = prefix + "/exedo/initsql/h2.sql";
}
else if ("hsqldb".equalsIgnoreCase(dss.getDialect())){
fileName = prefix + "/exedo/initsql/hsqldb.sql";
}
else{
this.setEchoValue(I18n.instance().get("现在只支持mysql、oracle、sqlserver、db2、hsqldb、h2和gae等数据库初始化!"));
return NO_FORWARD;
}
Connection con = null;
try {
con = dss.getConnection();
DatabaseMetaData meta = con.getMetaData();
String[] tblTypes = new String[] { "TABLE" };
String schema = null;
if (dss.isOracle()) {
if(dss.getUserName()!=null){
schema = dss.getUserName().trim().toUpperCase();
}
}
ResultSet rs = meta.getTables(null, schema, null, tblTypes);
while (rs.next()) {
String tableName = rs.getString("TABLE_NAME").toLowerCase();