Show
Ignore:
Timestamp:
07/08/08 19:12:15 (4 years ago)
Author:
amandel
Message:

Several fixes for Exceptions in current setup.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/java/org/jcoderz/phoenix/dbview/DbView.java

    r1011 r1066  
    6969import org.jcoderz.commons.util.DbUtil; 
    7070import org.jcoderz.commons.util.IoUtil; 
     71import org.jcoderz.commons.util.LoggingUtils; 
    7172import org.jcoderz.commons.util.XmlUtil; 
    7273 
     
    7980public class DbView 
    8081{ 
    81    /** Default database jndi name. */  
     82   /** Default database jndi name. */ 
    8283   public static final String DATASOURCE = "java:comp/env/jdbc/svs/db"; 
    8384 
     
    8586   public static final String LINE_SEPARATOR = Constants.LINE_SEPARATOR; 
    8687 
    87    private static final int MILLIS_PER_SECOND  
     88   private static final int MILLIS_PER_SECOND 
    8889           = org.jcoderz.commons.types.Date.MILLIS_PER_SECOND; 
    8990   private static final String SELECT_ALL_TABLES = "select * from tab"; 
     
    9394   private final Map mTypeMapper = new HashMap(); 
    9495   private final DateFormat mDateFormater 
    95          = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS",  
     96         = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS", 
    9697                 Constants.SYSTEM_LOCALE); 
    9798 
     
    182183            final String tableName = rs.getString(1); 
    183184            performConvertion( 
    184                   new File(dir, tableName + ".xml").getCanonicalPath(), 
    185                   dbConnection, "select * from " + tableName); 
     185                  new File(dir, 
     186                      escapeTableName(tableName) + ".xml").getCanonicalPath(), 
     187                      dbConnection, "select * from \"" + tableName + '"'); 
    186188         } 
    187189      } 
     
    239241            else if ("-loglevel".equals(args[i])) 
    240242            { 
    241                mLogLevel = Level.parse(args[i + 1]); 
     243               mLogLevel = Level.parse(args[++i]); 
    242244               Logger.getLogger("").setLevel(mLogLevel); 
     245               LoggingUtils.setGlobalHandlerLogLevel(mLogLevel); 
    243246            } 
    244247            else 
     
    331334         throws IOException, SQLException 
    332335   { 
     336      logger.fine("about to dump '" + query + "' into '" + fileName +"'."); 
    333337      PrintWriter out = null; 
    334338      PreparedStatement statement = null; 
     
    354358   } 
    355359 
    356    private Connection getConnectionFromDataSource ()  
     360   private Connection getConnectionFromDataSource () 
    357361       throws NamingException, SQLException 
    358362   { 
     
    558562   } 
    559563 
    560    private Object readBlob (ResultSet rs, int column)  
     564   private Object readBlob (ResultSet rs, int column) 
    561565         throws SQLException 
    562566   { 
     
    587591      final String result; 
    588592      final Reader reader = rs.getCharacterStream(column); 
    589       try 
    590       { 
    591          result = IoUtil.readFully(reader); 
    592       } 
    593       finally 
    594       { 
    595          IoUtil.close(reader); 
     593      if (reader != null) 
     594      { 
     595          try 
     596          { 
     597             result = IoUtil.readFully(reader); 
     598          } 
     599          finally 
     600          { 
     601             IoUtil.close(reader); 
     602          } 
     603      } 
     604      else 
     605      { 
     606          result = null; 
    596607      } 
    597608      return result; 
     
    721732         // ts.getTime does not return millis.... 
    722733         d = new Date(((ts.getTime() / MILLIS_PER_SECOND) * MILLIS_PER_SECOND) 
    723                + (ts.getNanos()  
     734               + (ts.getNanos() 
    724735                   / org.jcoderz.commons.types.Date.NANOS_PER_MILLI)); 
    725736      } 
     
    804815            else 
    805816            { 
    806                final IllegalArgumentException axe  
     817               final IllegalArgumentException axe 
    807818                     = new IllegalArgumentException( 
    808819                        "Could not map type for object '" + String.valueOf(in) 
     
    817828      } 
    818829   } 
     830 
     831   public static String escapeTableName (String in) 
     832   { 
     833       return in.replaceAll("[/\\\\$]", "#"); 
     834   } 
    819835}