001
014
015 package com.liferay.portal.verify;
016
017 import com.liferay.portal.kernel.dao.db.DB;
018 import com.liferay.portal.kernel.dao.db.DBManagerUtil;
019 import com.liferay.portal.kernel.dao.db.DBType;
020 import com.liferay.portal.kernel.dao.jdbc.DataAccess;
021 import com.liferay.portal.kernel.util.StringBundler;
022
023 import java.sql.PreparedStatement;
024 import java.sql.ResultSet;
025
026
029 public class VerifyDB2 extends VerifyProcess {
030
031 @Override
032 protected void doVerify() throws Exception {
033 DB db = DBManagerUtil.getDB();
034
035 if (db.getDBType() != DBType.DB2) {
036 return;
037 }
038
039 PreparedStatement ps = null;
040 ResultSet rs = null;
041
042 try {
043 StringBundler sb = new StringBundler(4);
044
045 sb.append("select tbname, name, coltype, length from ");
046 sb.append("sysibm.syscolumns where tbcreator = (select distinct ");
047 sb.append("current schema from sysibm.sysschemata) AND coltype = ");
048 sb.append("'VARCHAR' and length = 500");
049
050 ps = connection.prepareStatement(sb.toString());
051
052 rs = ps.executeQuery();
053
054 while (rs.next()) {
055 String tableName = rs.getString(1);
056
057 if (!isPortalTableName(tableName)) {
058 continue;
059 }
060
061 String columnName = rs.getString(2);
062
063 runSQL(
064 "alter table " + tableName + " alter column " + columnName +
065 " set data type varchar(600)");
066 }
067 }
068 finally {
069 DataAccess.cleanUp(ps, rs);
070 }
071 }
072
073 }