Changeset 1066 for trunk/src/java/org/jcoderz/phoenix/dbview/DbView.java
- Timestamp:
- 07/08/08 19:12:15 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/java/org/jcoderz/phoenix/dbview/DbView.java
r1011 r1066 69 69 import org.jcoderz.commons.util.DbUtil; 70 70 import org.jcoderz.commons.util.IoUtil; 71 import org.jcoderz.commons.util.LoggingUtils; 71 72 import org.jcoderz.commons.util.XmlUtil; 72 73 … … 79 80 public class DbView 80 81 { 81 /** Default database jndi name. */ 82 /** Default database jndi name. */ 82 83 public static final String DATASOURCE = "java:comp/env/jdbc/svs/db"; 83 84 … … 85 86 public static final String LINE_SEPARATOR = Constants.LINE_SEPARATOR; 86 87 87 private static final int MILLIS_PER_SECOND 88 private static final int MILLIS_PER_SECOND 88 89 = org.jcoderz.commons.types.Date.MILLIS_PER_SECOND; 89 90 private static final String SELECT_ALL_TABLES = "select * from tab"; … … 93 94 private final Map mTypeMapper = new HashMap(); 94 95 private final DateFormat mDateFormater 95 = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS", 96 = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS", 96 97 Constants.SYSTEM_LOCALE); 97 98 … … 182 183 final String tableName = rs.getString(1); 183 184 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 + '"'); 186 188 } 187 189 } … … 239 241 else if ("-loglevel".equals(args[i])) 240 242 { 241 mLogLevel = Level.parse(args[ i + 1]);243 mLogLevel = Level.parse(args[++i]); 242 244 Logger.getLogger("").setLevel(mLogLevel); 245 LoggingUtils.setGlobalHandlerLogLevel(mLogLevel); 243 246 } 244 247 else … … 331 334 throws IOException, SQLException 332 335 { 336 logger.fine("about to dump '" + query + "' into '" + fileName +"'."); 333 337 PrintWriter out = null; 334 338 PreparedStatement statement = null; … … 354 358 } 355 359 356 private Connection getConnectionFromDataSource () 360 private Connection getConnectionFromDataSource () 357 361 throws NamingException, SQLException 358 362 { … … 558 562 } 559 563 560 private Object readBlob (ResultSet rs, int column) 564 private Object readBlob (ResultSet rs, int column) 561 565 throws SQLException 562 566 { … … 587 591 final String result; 588 592 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; 596 607 } 597 608 return result; … … 721 732 // ts.getTime does not return millis.... 722 733 d = new Date(((ts.getTime() / MILLIS_PER_SECOND) * MILLIS_PER_SECOND) 723 + (ts.getNanos() 734 + (ts.getNanos() 724 735 / org.jcoderz.commons.types.Date.NANOS_PER_MILLI)); 725 736 } … … 804 815 else 805 816 { 806 final IllegalArgumentException axe 817 final IllegalArgumentException axe 807 818 = new IllegalArgumentException( 808 819 "Could not map type for object '" + String.valueOf(in) … … 817 828 } 818 829 } 830 831 public static String escapeTableName (String in) 832 { 833 return in.replaceAll("[/\\\\$]", "#"); 834 } 819 835 }
