rana_b 2002/10/29 09:08:02
Modified: ftpserver/src/java/org/apache/avalon/ftpserver/usermanager
DbUserManager.java
Log:
Removed block to create table autometically
Revision Changes Path
1.11 +6 -44
jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/usermanager/DbUserManager.java
Index: DbUserManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/usermanager/DbUserManager.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DbUserManager.java 10 Oct 2002 16:10:43 -0000 1.10
+++ DbUserManager.java 29 Oct 2002 17:08:02 -0000 1.11
@@ -27,10 +27,7 @@
/**
* This is another database based user manager class. I have
- * tested it using MySQL and Oracle database.
- *
- * If the table not found it tries to create one. The class then reads the table
- * structure from </code>ftp-db.sql</code> file and creates the table.
+ * tested it using MySQL and Oracle database. The sql file is
<code>ftp-db.sql</code>
*
* @phoenix:block
* @phoenix:service
name="org.apache.avalon.ftpserver.usermanager.UserManagerInterface"
@@ -40,7 +37,6 @@
public
class DbUserManager extends AbstractUserManager {
- private static final String COUNT_USERS_SQL = "SELECT COUNT(*) FROM FTP_USER";
private static final String GET_ALL_USERS_SQL = "SELECT LOGIN_ID FROM FTP_USER";
private static final String GET_USER_SQL = "SELECT * FROM FTP_USER WHERE
LOGIN_ID = ?";
private static final String NEW_USER_SQL = "INSERT INTO FTP_USER VALUES
(?, ?, ?, ?, ?, ?, ?, ?)";
@@ -55,6 +51,7 @@
private PreparedStatement mGetAllStmt = null;
private PreparedStatement mUpdUserStmt = null;
+
/**
* Instantiate user manager - default constructor.
*
@@ -63,6 +60,7 @@
public DbUserManager() throws Exception {
}
+
/**
* Set configuration - open database connection
*/
@@ -80,9 +78,6 @@
mDbConnection = DriverManager.getConnection(url, user, password);
mDbConnection.setAutoCommit(true);
- // create table if necessary
- createTable();
-
// prepare statements
mGetAllStmt = mDbConnection.prepareStatement( GET_ALL_USERS_SQL );
mGetUserStmt = mDbConnection.prepareStatement( GET_USER_SQL );
@@ -95,42 +90,8 @@
throw new ConfigurationException("DbUserManager.configure()", ex);
}
}
-
- /**
- * Create table if necesary
- */
- private void createTable() throws IOException, SQLException {
-
- // check table existance
- boolean bExist = false;
- try {
- String usrCnt = "SELECT COUNT(*) FROM FTP_USER";
- Statement stmt = mDbConnection.createStatement();
- ResultSet rs = stmt.executeQuery(usrCnt);
- rs.close();
- stmt.close();
- bExist = true;
- }
- catch(SQLException ex) {
- bExist = false;
- }
- if (bExist) {
- return;
- }
+
- // table does not exist - try to create
- getLogger().info("Table FTP_USER does non exist - creating table.");
- File sqlFile = new File(getContext().getBaseDirectory(), "ftp-db.sql");
- System.out.println(sqlFile.getAbsolutePath());
- FileReader reader = new FileReader(sqlFile);
- String sql = IoUtils.readFully(reader);
- reader.close();
-
- Statement stmt = mDbConnection.createStatement();
- stmt.execute(sql);
- stmt.close();
- }
-
/**
* Delete user. Delete the row from the table.
*/
@@ -138,6 +99,7 @@
mDelUserStmt.setString(1, name);
mDelUserStmt.executeUpdate();
}
+
/**
* Save user. If new insert a new row, else update the existing row.
--
To unsubscribe, e-mail: <mailto:avalon-cvs-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@;jakarta.apache.org>