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