Make sure we have the column or index before we drop it. Unwrapped a non-long
line. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1860 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -459,7 +459,7 @@ public class JDBCUtil
|
|||||||
String cname, String cdef, String afterCname)
|
String cname, String cdef, String afterCname)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
if (JDBCUtil.tableContainsColumn(conn, table, cname)) {
|
if (tableContainsColumn(conn, table, cname)) {
|
||||||
// Log.info("Database table '" + table + "' already has column '" +
|
// Log.info("Database table '" + table + "' already has column '" +
|
||||||
// cname + "'.");
|
// cname + "'.");
|
||||||
return;
|
return;
|
||||||
@@ -517,8 +517,11 @@ public class JDBCUtil
|
|||||||
public static void dropColumn (Connection conn, String table, String cname)
|
public static void dropColumn (Connection conn, String table, String cname)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
String update = "ALTER TABLE " + table + " DROP COLUMN " + cname;
|
if (!tableContainsColumn(conn, table, cname)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String update = "ALTER TABLE " + table + " DROP COLUMN " + cname;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = conn.prepareStatement(update);
|
stmt = conn.prepareStatement(update);
|
||||||
@@ -530,15 +533,18 @@ public class JDBCUtil
|
|||||||
close(stmt);
|
close(stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a named index from the specified table.
|
* Removes a named index from the specified table.
|
||||||
*/
|
*/
|
||||||
public static void dropIndex (Connection conn, String table, String iname)
|
public static void dropIndex (Connection conn, String table, String iname)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
String update = "ALTER TABLE " + table + " DROP INDEX " + iname;
|
if (!tableContainsIndex(conn, table, iname)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String update = "ALTER TABLE " + table + " DROP INDEX " + iname;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = conn.prepareStatement(update);
|
stmt = conn.prepareStatement(update);
|
||||||
@@ -550,7 +556,7 @@ public class JDBCUtil
|
|||||||
close(stmt);
|
close(stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the primary key from the specified table.
|
* Removes the primary key from the specified table.
|
||||||
*/
|
*/
|
||||||
@@ -579,7 +585,7 @@ public class JDBCUtil
|
|||||||
String cname, String iname)
|
String cname, String iname)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
if (JDBCUtil.tableContainsIndex(conn, table, cname, iname)) {
|
if (tableContainsIndex(conn, table, cname, iname)) {
|
||||||
// Log.info("Database table '" + table + "' already has an index " +
|
// Log.info("Database table '" + table + "' already has an index " +
|
||||||
// "on column '" + cname + "'" +
|
// "on column '" + cname + "'" +
|
||||||
// (iname != null ? " named '" + iname + "'." : "."));
|
// (iname != null ? " named '" + iname + "'." : "."));
|
||||||
|
|||||||
@@ -111,8 +111,7 @@ public class UserRepository extends JORARepository
|
|||||||
public User loadUser (String username)
|
public User loadUser (String username)
|
||||||
throws PersistenceException
|
throws PersistenceException
|
||||||
{
|
{
|
||||||
return loadUserWhere("where username = " +
|
return loadUserWhere("where username = " + JDBCUtil.escape(username));
|
||||||
JDBCUtil.escape(username));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user