是否有一种方法可以使用UCANACESS在数据库中与特定名称匹配的所有列上选择并执行查询

我尝试使用在Find all tables that have X column name中找到的MYSQL方法

String sql = "SELECT DISTINCT table_name FROM INFORMATION_SCHEMA.COLUMNS WHERE column_name= 'CID'";



        ResultSet rs = readID.executeQuery(sql);
        System.out.println("This plugin has successfully connected to the database...");
        do {
            userInput2 = JOptionPane.showInputDialog(null,"HIPAA Main Menu \n1. Encrypt the database. \n2. Decrypt the database.\n3. Exit the program.\n(Make a selection by entering 1, 2, or 3)");
            choice = Integer.parseInt(userInput2);
            switch (choice) {
                case 1 :
                    while (rs.next()) {
                        ID = rs.getString("CID");
                        rs.updateString("CID", encodedID(ID,aesKey,cipher));
                        rs.updateRow();
                        x++;
                    }
                    dbConnection.commit();


ResultSet rs = readID.executeQuery(sql);

我希望代码可以连接到数据库中名为CID的任何列,然后获取列中的字符串,但是,我收到以下错误...

此插件已成功连接到数据库...
net.ucanaccess.jdbc.UcanaccessSQLException:UCAExc ::: 4.0.4找不到列:CID
    在net.ucanaccess.jdbc.UcanaccessResultSet.getString(UcanaccessResultSet.java:782)
    在Hipaa.main(Hipaa.java:63)
引起原因:net.ucanaccess.jdbc.UcanaccessSQLException:UCAExc ::: 4.0.4找不到列:CID
    在net.ucanaccess.jdbc.UcanaccessResultSet.getObject(UcanaccessResultSet.java:649)
    在net.ucanaccess.jdbc.UcanaccessResultSet.getString(UcanaccessResultSet.java:776)
    ...还有1个

最佳答案

尝试将此行更改为:

字符串sql =“ SELECT INFORMATION DISTINCT table_name from INFORMATION_SCHEMA.COLUMNS WHERE column_name ='CID'”;

并尝试再次运行它
希望这会起作用

关于java - 选择所有具有匹配列名的表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57597079/

10-10 23:53