This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.IOException; | |
import java.util.HashMap; | |
import java.util.Map; | |
import com.healthmarketscience.jackcess.Cursor; | |
import com.healthmarketscience.jackcess.Database; | |
import com.healthmarketscience.jackcess.DatabaseBuilder; | |
import com.healthmarketscience.jackcess.Table; | |
public class DeleteTable { | |
public static void main(String[] args) { | |
String db_name = "/home/xxxx/Dropbox/doc/mdb/jack.mdb"; | |
String table_name = "sample_table0"; | |
File file = new File(db_name); | |
Database db=null; | |
try { | |
db = DatabaseBuilder.open(file); | |
Table tbl=db.getSystemTable("MSysObjects"); | |
Cursor crsr = tbl.getDefaultCursor(); | |
Map<String,Object> findCriteria = new HashMap<String,Object>(); | |
findCriteria.put("Name",table_name); | |
findCriteria.put("Type",(short)1); | |
if(crsr.findFirstRow(findCriteria)){ | |
tbl.deleteRow(crsr.getCurrentRow()); | |
System.out.println("table deleted:" + table_name); | |
}else{ | |
System.out.println("there is no table:" + table_name); | |
} | |
db.close(); | |
} catch (IOException e) { | |
System.out.println(e.getMessage()); | |
}catch(Exception ee){ | |
System.out.println(ee.getMessage()); | |
} | |
} | |
} |
0 件のコメント:
コメントを投稿