void truncateTable() throws IOException { if ( table == null ) { return; } Cursor tableRows = Cursor.createCursor( table ); while ( tableRows.moveToNextRow() ) { tableRows.deleteCurrentRow(); } } }
void openDatabase( File databaseFile ) throws IOException { db = Database.open( databaseFile ); }
void addRowToTable( Object... row ) throws IOException { table.addRow( row ); }
public static final RowMetaInterface getLayout( Table table ) throws SQLException, KettleStepException { RowMetaInterface row = new RowMeta(); List<Column> columns = table.getColumns(); for ( int i = 0; i < columns.size(); i++ ) { Column column = columns.get( i ); int type = column.getType().getSQLType(); switch ( type ) { case java.sql.Types.CHAR: case java.sql.Types.LONGVARCHAR: // Character Large Object valtype = ValueMetaInterface.TYPE_STRING; length = column.getLength(); break; case java.sql.Types.NUMERIC: valtype = ValueMetaInterface.TYPE_NUMBER; length = column.getLength(); precision = column.getPrecision(); if ( length >= 126 ) { length = -1; length = column.getLength(); break; v = ValueMetaFactory.createValueMeta( column.getName(), valtype ); } catch ( KettlePluginException e ) { throw new KettleStepException( e );
Database d = Database.open( new File( AccessInputMeta.getFilename( inputList.getFile( 0 ) ) ), true ); String realTableName = transMeta.environmentSubstitute( meta.getTableName() ); t = d.getSystemTable( realTableName ); } else { t = d.getTable( realTableName ); List<Column> col = t.getColumns(); int nr = col.size(); for ( int i = 0; i < nr; i++ ) {
Database.create( targetDbFile ); logBasic( BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.Log.DbCreated", targetFilename ) ); } else { Database db = Database.open( targetDbFile ); logBasic( BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.Log.DbOpened", targetFilename ) ); if ( db.getTable( tablename ) != null ) { logBasic( BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.Log.TableExists", tablename ) ); db.close(); Database.open( targetDbFile ).importFile( tablename, sourceDataFile, delimiter );
DataType type = c.getType(); sourceValueMeta = ValueMetaFactory.createValueMeta( name == null ? c.getName() : name, sourceValueType ); } catch ( KettlePluginException e ) { sourceValueMeta = new ValueMetaNone( name == null ? c.getName() : name ); sourceValueMeta.setLength( c.getLength(), c.getPrecision() );
Database.open( new File( AccessInputMeta.getFilename( fileInputList.getFile( 0 ) ) ), true ); Set<String> settables = accessDatabase.getTableNames(); settables.addAll( accessDatabase.getSystemTableNames() ); accessDatabase.close();
database = Database.open( file ); Set<String> set = database.getTableNames(); String[] tablenames = set.toArray( new String[set.size()] ); EnterSelectionDialog dialog = database.close();
void createTable( String tableName, RowMetaInterface rowMeta ) throws IOException { List<Column> columns = AccessOutputMeta.getColumns( rowMeta ); db.createTable( tableName, columns ); table = db.getTable( tableName ); }
void closeDatabase() throws IOException { db.close(); }
data.table = data.db.getTable( realTablename ); if ( data.table == null ) { if ( meta.isTableCreated() ) {
private Object[] getOneRow() throws KettleException { try { if ( meta.isFileField() ) { while ( ( data.readrow == null || ( ( data.rw = data.t.getNextRow() ) == null ) ) ) { if ( !openNextFile() ) { return null; while ( ( data.file == null || ( ( data.rw = data.t.getNextRow() ) == null ) ) ) { if ( !openNextFile() ) { return null; if ( meta.isIncludeTablename() && !Utils.isEmpty( data.t.getName() ) ) { r[rowIndex++] = data.t.getName();
Column column = new Column(); column.setName( value.getName() ); case ValueMetaInterface.TYPE_INTEGER: if ( length < 3 ) { column.setType( DataType.BYTE ); length = DataType.BYTE.getFixedSize(); } else { if ( length < 5 ) { column.setType( DataType.INT ); length = DataType.INT.getFixedSize(); } else { column.setType( DataType.LONG ); length = DataType.LONG.getFixedSize(); column.setType( DataType.DOUBLE ); length = DataType.DOUBLE.getFixedSize(); break; case ValueMetaInterface.TYPE_DATE: column.setType( DataType.SHORT_DATE_TIME ); length = DataType.SHORT_DATE_TIME.getFixedSize(); break; case ValueMetaInterface.TYPE_STRING: if ( length < 255 ) { column.setType( DataType.TEXT ); length *= DataType.TEXT.getUnitSize(); } else { column.setType( DataType.MEMO ); length *= DataType.MEMO.getUnitSize();
new DatabaseBuilder().setup("MyDatabase").initialize(table).close();
void addRowsToTable( List<Object[]> rows ) throws IOException { table.addRows( rows ); }
private Object convert( Object obj, AccessInputField field, int index ) throws Exception { // Get column Column c = data.t.getColumn( field.getColumn() ); // Find out field type ValueMetaAndData sourceValueMetaAndData = AccessInputMeta.getValueMetaAndData( c, field.getName(), obj ); // DO CONVERSIONS... // ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( data.totalpreviousfields + index ); return targetValueMeta.convertData( sourceValueMetaAndData.getValueMeta(), sourceValueMetaAndData .getValueData() ); } }
void createDatabase( File databaseFile ) throws IOException { db = Database.create( databaseFile ); }
public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { meta = (AccessInputMeta) smi; data = (AccessInputData) sdi; if ( data.t != null ) { data.t = null; } if ( data.rw != null ) { data.rw = null; } if ( data.readrow != null ) { data.readrow = null; } try { if ( data.d != null ) { data.d.close(); data.d = null; } if ( data.file != null ) { data.file.close(); data.file = null; } data.daf = null; } catch ( Exception e ) { // ignore this } super.dispose( smi, sdi ); }