开发者

How to execute Multiple "Create Table... " Statements in ACCESS Database

I have 480 "Create table" statements to be inserted into an empty access db. I found the access has no option of multiple query executions...

I have all the create table queries in a text file

Please help me, how can this be achieved.

I am using MS Access 2007. The access db is in local harddrive开发者_JAVA百科

Thanks Ramm


I did this java sample. It worked.. Please let me know if any simple process for this.

import java.io.*;
import java.util.*;
import java.text.*;
import java.sql.*;
import org.apache.poi.ss.usermodel.*;


public class DirReader_fat {

public static void main(String[] args) {

  String inputFilePath = "D:\\Sample.xlsx";
  String strInputQuery = "";

  try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        String filename = "d:\\Empty_1.mdb";

        String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
        database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end 

        // now we can get the connection from the DriverManager
        Connection con = DriverManager.getConnection( database ,"",""); 

        // try and create a java.sql.Statement so we can run queries
        Statement s = con.createStatement();

        InputStream inputStream = new FileInputStream(new File(inputFilePath));
        Workbook wb = WorkbookFactory.create(inputStream);
        Sheet sheet = wb.getSheet("Sheet1");
        for (Row row : sheet) {

            strInputQuery = row.getCell(0).toString();
            s.execute(strInputQuery);
        }

  }catch (Exception e) {
        e.printStackTrace();
    }
 }

 }

Thanks Ramm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜