Renamed addColumnToTable to addColumn, added an optional argument for the
column name after which to add the new one. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1468 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -281,9 +281,12 @@ public class JDBCUtil
|
|||||||
/**
|
/**
|
||||||
* Adds a column (with name 'cname' and definition 'cdef') to the
|
* Adds a column (with name 'cname' and definition 'cdef') to the
|
||||||
* specified table.
|
* specified table.
|
||||||
|
*
|
||||||
|
* @param afterCname (optional) the name of the column after which to
|
||||||
|
* add the new column.
|
||||||
*/
|
*/
|
||||||
public static void addColumnToTable (Connection conn, String table,
|
public static void addColumn (Connection conn, String table,
|
||||||
String cname, String cdef)
|
String cname, String cdef, String afterCname)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
if (JDBCUtil.tableContainsColumn(conn, table, cname)) {
|
if (JDBCUtil.tableContainsColumn(conn, table, cname)) {
|
||||||
@@ -292,8 +295,11 @@ public class JDBCUtil
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String update = "ALTER TABLE " + table + " ADD COLUMN " + cname + " " +
|
String update = "ALTER TABLE " + table + " ADD COLUMN " +
|
||||||
cdef;
|
cname + " " + cdef;
|
||||||
|
if (afterCname != null) {
|
||||||
|
update += " AFTER " + afterCname;
|
||||||
|
}
|
||||||
|
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user