当前位置: 首页 > 知识库问答 >
问题:

ucanaccess中的查询输出不正确

倪棋
2023-03-14

我有一个accdb文件。我正在使用ucanaccess api从我的Java项目连接到它并处理数据。(我没有MS Access,我在Java项目中使用ucanaccess作为引用库)。

但是,当我在SQL server中导入accdb文件并运行查询select B.grd,B.[credit hours],B.term from[1i-stem dcccd student courses]B where[student id]='2169095';时,我遇到了一个奇怪的问题:

但是当我在ucanaccess中运行查询时,我会得到以下输出:

    Please, enter the full path to the access file (.mdb or accdb): C:\\Users\\Tejas\\Desktop\\sample.accdb
log4j:WARN No appenders could be found for logger (com.healthmarketscience.jackcess.impl.DatabaseImpl).
log4j:WARN Please initialize the log4j system properly.
WARNING:External file P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb does not exist
WARNING:given file does not exist: P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb
WARNING:External file P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb does not exist
WARNING:given file does not exist: P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb
WARNING:External file P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb does not exist
WARNING:given file does not exist: P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb
WARNING:External file P:\IE\Warehouse (New 1-27-15)\GPA - Standing.mdb does not exist
WARNING:given file does not exist: P:\IE\Warehouse (New 1-27-15)\GPA - Standing.mdb
WARNING:External file P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb does not exist
WARNING:given file does not exist: P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb
WARNING:External file P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb does not exist
WARNING:given file does not exist: P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb
WARNING:External file P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb does not exist
WARNING:given file does not exist: P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb
WARNING:External file P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb does not exist
WARNING:given file does not exist: P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb
WARNING:External file P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb does not exist
WARNING:given file does not exist: P:\IE\Warehouse (New 1-27-15)\MVC Data Warehouse.mdb
WARNING:Error in the metadata of the table 12i-Fac Info: table's row count in the metadata is 1642 but 1652 records have been found and loaded by UCanAccess. All will work fine, but it's better to repair your database.
WARNING:Error in the metadata of the table 3i-STEM STUDENTS LOAD BY TERM: table's row count in the metadata is 8716 but 4358 records have been found and loaded by UCanAccess. All will work fine, but it's better to repair your database.
Error occured at the first loading attempt of 12i-Faculty Latetst Information
Converted view was :CREATE VIEW "Z_12I-FACULTY LATETST INFORMATION" AS SELECT "STUDENT COURSE"."FAC ID", Last("STUDENT COURSE"."FACULTY LAST NAME") AS "LASTOFFACULTY LAST NAME", Last("STUDENT COURSE"."FACULTY FIRST NAME") AS "LASTOFFACULTY FIRST NAME"
FROM "STUDENT COURSE"
GROUP BY "STUDENT COURSE"."FAC ID"
Error message was :user lacks privilege or object not found: STUDENT COURSE
Loaded Tables:
10i-STEM STUDENT LATEST MAJOR INFORMATION, 12i-Fac Info, 13-F1 students by Term, 14i- Faculty Per Term, 15i- STEM COURSE MASTER, 15i- STEM COURSE MASTER by TERM, 1i-STEM DCCCD STUDENT COURSES, 2i - STEM latest Student Information, 3i-STEM STUDENTS LOAD BY TERM, 4i-STEM STUDENT Latest GPA, 5i-STEM MVC STUDENT COURSE 2014-15AY, 6-Financial AID By Sum of Term Amt, 7-STEM - ACAD YR MASTER, 7-STEM MVC Acad-YR TERM, 8i-STEM STUDENT COURSE STATUS BY TERM, 9-STEM TERM MASTER, Financial AID By Sum of Term Amt, STEM TERM VALUES
Loaded Queries:
2014-15AY STEM STUDENT UNIQ ID AS OF 6-4-15, 2i-STEM UNIQUE STUDENT LATEST TERM
Loaded Indexes:
Primary Key  on 1i-STEM DCCCD STUDENT COURSES Columns: (ID) 
, Primary Key  on 5i-STEM MVC STUDENT COURSE 2014-15AY Columns: (ID) 
, Primary Key  on STEM TERM VALUES Columns: (Term Code) 
, Index on 12i-Fac Info Columns: (FAC ID) 
, Index on 7-STEM - ACAD YR MASTER Columns: (CODE) 
, Index on STEM TERM VALUES Columns: (Term Code) 

Cannot load view MVC Acad_YR - TERM : user lacks privilege or object not found: STUDENT COURSE
Cannot load view 12i-Faculty Latetst Information : user lacks privilege or object not found: STUDENT COURSE
Cannot load view 4i-STEM STUDENTS Latest GPA - 3 : user lacks privilege or object not found: GPA - TERM AND CUMM
Cannot load view Update the Term Master : user lacks privilege or object not found: STUDENT COURSE
Cannot resolve table 5- STEM MVC Course
Cannot resolve table Course
Cannot resolve table First Time in College
Cannot resolve table GPA - Term and Cumm
Cannot resolve table Student
Cannot resolve table Student Course
Cannot resolve table Student Financial Aid
Cannot resolve table Student Load
Cannot resolve table Student Type
UCanAccess>
Copyright (c) 2012 Marco Amadei
UCanAccess version 3.0.1
You are connected!! 
Type quit to exit 

Commands end with ; 

use:   
   export <pathToCsv>;
for exporting into a .csv file the result set from the last executed query

UCanAccess>SELECT B.grd , b.[credit hours] , b.term from  [1i-stem dcccd student courses] B where [student id] = '2169095';
------------------------------
| GRD | Credit Hours | Term | 
------------------------------

| W | 4.0 | 2009FA | 

| F | 3.0 | 2009FA | 

| A | 3.0 | 2009FA | 

| F | 3.0 | 2009FA | 

| F | 3.0 | 2010SP | 

| F | 3.0 | 2010SP | 

| F | 3.0 | 2010SP | 

| C | 4.0 | 2010SP | 

| F | 3.0 | 2010SP | 

| D | 3.0 | 2012S2 | 

| C | 3.0 | 2012S2 | 

| A | 4.0 | 2014FA | 

| A | 4.0 | 2015SP | 

| A | 4.0 | 2015SP | 

| null | 4.0 | 2015FA | 

| null | 4.0 | 2015FA | 


UCanAccess>

还有其他类似的不忠行为。与在SQL server中一样,对于特定查询,其中一个列输出为'a',但在ucanaccess中为'NULL'。

我怎么解决这个?

共有1个答案

越心水
2023-03-14

首先,您使用的是旧的2.0.9.5版本,因此,如果您使用最新的3.0.1,并在第一步使用3.0.1输出更新您的问题,那就太好了。其次,数据库可能已损坏,可以使用MS Access Compact and Repair工具进行修复。但是,执行以下代码(jackcess)并让我们知道您的发现(程序输出)可能非常有用。

package net.ucanaccess.test;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Iterator;

import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.DatabaseBuilder;
import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.Table;


public class Jackcess {
    public static void main(String[] d) throws IOException, SQLException{
        DatabaseBuilder dbd =new DatabaseBuilder(new File("Path to your file"));
        dbd.setAutoSync(false);
        Database db=dbd.open();
        Table t=db.getTable("1i-stem dcccd student courses");
        System.out.println(t);
          Iterator<Row> it=t.iterator();
          while(it.hasNext()){
              System.out.println(it.next());
          }
    }

}
 类似资料:
  • 问题内容: 我有一个普通的选择查询,其结果如下输出。 我希望它重写输出以下输出。 如何做到这一点? 问题答案: 这是仅通过子查询和聚合来完成此操作的一种方法: 您也可以使用,但这是Oracle SQL的最新功能,因此我倾向于使用此方法。

  • 我有一个名为TEST的表,列名为col1、col2、col3、col4。。。。。。。。。。所以,从信息模式来看。列我将获得有关此表对象的详细信息。 现在,我想通过从信息_模式中提供列名称,从测试表中构建一个select查询。柱。像这样,从information_schema中选择column_name。表_name='TEST'中的列。这会回来的 col1 col2 col3 我想在selectq

  • 我一直在研究一个问题,这个问题涉及到取多个数字对,并创建某种形式的和循环,将每对相加。 我没有得到正确的输出数,例如输入了15对数字,只有8对输出。 这是我到目前为止的代码。。。 我错过了什么?

  • 我有一个复合密钥的实体。订阅和源具有多对多的关系。 我正在使用Spring数据存储库来处理它。 当我尝试使用方法saveAll时,它会抛出 “com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception:未知列'subscripti0_.subscription_id'” 同时尝试在保存后返回值。 Hibernate生成以下查询: 所以,现在我

  • 我正在使用hibernate data JPA。这是我的资源库 公共接口MappingRepository扩展了JpaRepository(ConfigMapping,Long){ 现在在我的服务类中,当我试图通过使用 所以我总是遇到例外 注意:vMList是作为Long列表的VM列表

  • 问题内容: 我有一个我无法解决的问题。我正在使用PHP通过数据库运行以下命令: 结果全部恢复正常,并且符合预期,但是我必须将其输入折线图中,但是当我这样做时,它们显然会反向显示,因为我有数据库按日期在DESC中返回它们,这意味着最新的将是第一个返回。 有没有一种方法可以在返回这些结果之后在将数据输入到图表之前反转它们的顺序。 这是完整的查询(请不要对使用mysql而不是mysqli进行评论,我没有