This commit is contained in:
parent
47849b61ec
commit
eb5911ac7d
4 changed files with 23 additions and 6 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package zutil.db;
|
package zutil.db;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
|
@ -37,7 +38,7 @@ import javax.sql.DataSource;
|
||||||
import zutil.db.handler.SimpleSQLHandler;
|
import zutil.db.handler.SimpleSQLHandler;
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
|
|
||||||
public class DBConnection{
|
public class DBConnection implements Closeable{
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
private static final Logger logger = LogUtil.getLogger();
|
||||||
|
|
||||||
public enum DBMS{
|
public enum DBMS{
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package zutil.db;
|
package zutil.db;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.io.Closeable;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
@ -33,7 +33,7 @@ import zutil.db.DBConnection.DBMS;
|
||||||
*
|
*
|
||||||
* @author Ziver
|
* @author Ziver
|
||||||
*/
|
*/
|
||||||
public class DBConnectionPool extends TimerTask {
|
public class DBConnectionPool extends TimerTask implements Closeable{
|
||||||
public static final long DEFAULT_TIMEOUT = 10*60*60*1000; // 10 minutes;
|
public static final long DEFAULT_TIMEOUT = 10*60*60*1000; // 10 minutes;
|
||||||
public static final int DEFAULT_MAX_SIZE = 5;
|
public static final int DEFAULT_MAX_SIZE = 5;
|
||||||
|
|
||||||
|
|
@ -150,7 +150,7 @@ public class DBConnectionPool extends TimerTask {
|
||||||
/**
|
/**
|
||||||
* Closes all the connections
|
* Closes all the connections
|
||||||
*/
|
*/
|
||||||
public synchronized void close() throws SQLException{
|
public synchronized void close(){
|
||||||
for( PoolItem item : inusePool ){
|
for( PoolItem item : inusePool ){
|
||||||
item.conn.forceClose();
|
item.conn.forceClose();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@ public class FileUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the extension of the file
|
* Returns the extension(without the dot) of the file. e.g. "png" "avi"
|
||||||
*
|
*
|
||||||
* @param file is the file
|
* @param file is the file
|
||||||
* @return The extension
|
* @return The extension
|
||||||
|
|
@ -292,4 +292,19 @@ public class FileUtil {
|
||||||
return file.substring(file.lastIndexOf(".")+1, file.length());
|
return file.substring(file.lastIndexOf(".")+1, file.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the current extension on the file withe the given one.
|
||||||
|
*
|
||||||
|
* @param filename is the name of the file
|
||||||
|
* @param string is the new extension, without the dot
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String changeExtension(String file, String ext) {
|
||||||
|
if( file == null )
|
||||||
|
return null;
|
||||||
|
if( file.lastIndexOf(".") == -1 )
|
||||||
|
return file+"."+ext;
|
||||||
|
return file.substring(0, file.lastIndexOf(".")+1)+ext;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,12 @@ public class FileUploadListener implements ProgressListener{
|
||||||
this.item = pItems;
|
this.item = pItems;
|
||||||
|
|
||||||
// Calculate Speed
|
// Calculate Speed
|
||||||
if(speedTime == 0 || speedTime+1000<System.currentTimeMillis()){
|
if(speedTime == 0 || speedTime+1000 < System.currentTimeMillis() || pBytesRead == pContentLength){
|
||||||
speedTime = System.currentTimeMillis();
|
speedTime = System.currentTimeMillis();
|
||||||
speed = (int)(pBytesRead-speedRead);
|
speed = (int)(pBytesRead-speedRead);
|
||||||
speedRead = pBytesRead;
|
speedRead = pBytesRead;
|
||||||
}
|
}
|
||||||
|
//try{Thread.sleep(10);}catch(Exception e){}
|
||||||
|
|
||||||
// Set Status
|
// Set Status
|
||||||
status = Status.Uploading;
|
status = Status.Uploading;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue