|
From: Michael K. <ko...@us...> - 2004-07-05 07:58:58
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23424/db Modified Files: DBAccess.java DBAccessImpl.java Log Message: Moved resource loading to new ResourceUtil class. Index: DBAccessImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db/DBAccessImpl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- DBAccessImpl.java 24 Jun 2004 06:55:36 -0000 1.8 +++ DBAccessImpl.java 5 Jul 2004 07:58:01 -0000 1.9 @@ -25,6 +25,7 @@ import org.cobricks.core.CobricksException; import org.cobricks.core.CoreManager; import org.cobricks.core.util.LogUtil; +import org.cobricks.core.util.ResourceUtil; import org.cobricks.user.*; @@ -208,6 +209,7 @@ // for all components check subdirectory db, load the tables.txt file // and then load all files referenced in this file String components = properties.getProperty("components"); + if (components == null) return; StringTokenizer st = new StringTokenizer(components, ","); while (st.hasMoreTokens()) { String compname = st.nextToken(); @@ -218,8 +220,8 @@ } List tables = new ArrayList(); try { - InputStream is = coreManager. - getComponentResourceAsStream(compname, "db/tables.txt"); + InputStream is = + ResourceUtil.getComponentResourceAsStream(compname, "db/tables.txt"); if (is == null) continue; BufferedReader in = new BufferedReader(new InputStreamReader(is)); if (in == null) continue; @@ -258,8 +260,8 @@ tableDescriptors.put(tablename, td); } String resourcename = "/"+compname.replace('.', '/')+"/db/"+tablename+".xml"; - InputStream is = coreManager. - getComponentResourceAsStream(compname, "db/"+tablename+".xml"); + InputStream is = + ResourceUtil.getComponentResourceAsStream(compname, "db/"+tablename+".xml"); if (is == null) return null; td.readFromInputStream(is); return tablename; @@ -1157,6 +1159,12 @@ } } + + public Connection getConnection() + throws SQLException + { + return dataSource.getConnection(); + } } Index: DBAccess.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db/DBAccess.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- DBAccess.java 24 Jun 2004 06:55:35 -0000 1.5 +++ DBAccess.java 5 Jul 2004 07:58:01 -0000 1.6 @@ -13,7 +13,12 @@ package org.cobricks.core.db; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.sql.Connection; +import java.sql.SQLException; import org.cobricks.core.CobricksException; import org.cobricks.core.CoreManager; @@ -80,4 +85,7 @@ // convert a generic type name to a database specific type name public String getColumnTypeForCreateTable(String coltype); + public Connection getConnection() + throws SQLException; + } |
|
From: Michael K. <ko...@us...> - 2004-07-16 08:19:06
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25347/db Modified Files: DBAccess.java DBAccessImpl.java Log Message: Index: DBAccessImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db/DBAccessImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- DBAccessImpl.java 5 Jul 2004 07:58:01 -0000 1.9 +++ DBAccessImpl.java 16 Jul 2004 08:18:56 -0000 1.10 @@ -576,6 +576,35 @@ /** + * Delete rows from the given table. + */ + public void sqlDelete(String tablename, String where) + { + logger.debug("sqlDelete("+tablename+","+where+")"); + + StringBuffer sb = new StringBuffer("delete from "); + sb.append(tablename); + sb.append(" where "); + sb.append(where); + + Connection conn = null; + PreparedStatement pstmt = null; + try { + conn = dataSource.getConnection(); + pstmt = conn.prepareStatement(sb.toString()); + pstmt.execute(); + pstmt.close(); + } catch(Exception e) { + logger.error(LogUtil.ex("Failed executing sql statement: " + +sb.toString(), e)); + } finally { + try { pstmt.close(); } catch (Exception e) { } + try { conn.close(); } catch (Exception e) { } + } + } + + + /** * Update a row in the given table.This method constructs an attribute * name list and calls the sqlUpdate() function with the additional * parameter. Index: DBAccess.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db/DBAccess.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- DBAccess.java 5 Jul 2004 07:58:01 -0000 1.6 +++ DBAccess.java 16 Jul 2004 08:18:56 -0000 1.7 @@ -51,6 +51,7 @@ public void sqlDelete(String tablename, int primaryKey); public void sqlDelete(String tablename, Map attrs); + public void sqlDelete(String tablename, String where); public void sqlUpdate(String tablename, List attrnames, Map attrs, String where); |
|
From: Michael K. <ko...@us...> - 2005-10-21 15:56:54
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17863/core/db Modified Files: DBAccess.java DBAccessImpl.java Log Message: Index: DBAccessImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db/DBAccessImpl.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- DBAccessImpl.java 22 Aug 2005 13:52:06 -0000 1.19 +++ DBAccessImpl.java 21 Oct 2005 15:56:46 -0000 1.20 @@ -83,7 +83,8 @@ getClassLoader()); } catch (Exception e) { logger.error("Failed initializing JDBC driver class "+jdbcDriver); - throw new CobricksException(e.toString()); + throw new CobricksException("Failed initializing JDBC driver: " + +e.toString()); } // collect connection parameters Index: DBAccess.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db/DBAccess.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- DBAccess.java 19 Jan 2005 15:36:54 -0000 1.8 +++ DBAccess.java 21 Oct 2005 15:56:46 -0000 1.9 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004 Cobricks Group. All rights reserved. + * Copyright (c) 2003-2005 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the Cobricks Software |
|
From: Michael K. <ko...@us...> - 2006-01-03 09:35:28
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22419/db Modified Files: DBAccess.java DBAccessImpl.java Log Message: Support for searching child classes Index: DBAccessImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db/DBAccessImpl.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- DBAccessImpl.java 20 Dec 2005 18:10:24 -0000 1.24 +++ DBAccessImpl.java 3 Jan 2006 09:35:20 -0000 1.25 @@ -1175,10 +1175,16 @@ } + public void sqlExecute(String sql) + { + sqlExecute(sql, false); + } + /** * Execute the given SQL statement. + * @param donotlogerrors if true, then exceptions will not be logged */ - public void sqlExecute(String sql) + public void sqlExecute(String sql, boolean donotlogerrors) { if (sql==null || sql.trim().length()<1) return; logger.debug("sqlExecute("+sql+")"); @@ -1190,7 +1196,11 @@ if (dbtype == DBTYPE_ORACLE) stmt.setEscapeProcessing(false); stmt.executeUpdate(sql); } catch(Exception e) { - logger.error(LogUtil.ex("Failed executing sql statement: "+sql, e)); + if (donotlogerrors) + logger.error("Failed executing sql statement"); + else + logger.error(LogUtil.ex("Failed executing sql statement: " + +sql, e)); } finally { try { stmt.close(); } catch (Exception e) { } try { conn.close(); } catch (Exception e) { } Index: DBAccess.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/db/DBAccess.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- DBAccess.java 21 Oct 2005 15:56:46 -0000 1.9 +++ DBAccess.java 3 Jan 2006 09:35:20 -0000 1.10 @@ -68,6 +68,7 @@ public Map sqlQuerySingleRow(String sql); public void sqlExecute(String sql); + public void sqlExecute(String sql, boolean donotlogerrors); // create a new value for the primary key column of the given table public String getNewPrimaryKey(String tablename, String primarykeycol); |