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

用java连接到firebird/odbc(orgaMax)数据库时出错

尉迟浩思
2023-03-14
Exception in thread "main" org.firebirdsql.jdbc.FBSQLException: GDS Exception. 3
35544344. I/O error during "CreateFile (open)" operation for file "C:\PROGRAMMDA
TA\DELTRA\ORGAMAX\DB\DB1.FDB"
Error while trying to open file
null
        at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:120
)
        at org.firebirdsql.jdbc.AbstractDriver.connect(AbstractDriver.java:136)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at at.orgamax.connector.Connector.main(Connector.java:1
9)
Caused by: org.firebirdsql.gds.GDSException: I/O error during "CreateFile (open)
" operation for file "C:\PROGRAMMDATA\DELTRA\ORGAMAX\DB\DB1.FDB"
Error while trying to open file
null
        at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.readStatusVector(Ab
stractJavaGDSImpl.java:2120)
        at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.receiveResponse(Abs
tractJavaGDSImpl.java:2070)
        at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.internalAttachDatab
ase(AbstractJavaGDSImpl.java:461)
        at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscAttachDatabase(A
bstractJavaGDSImpl.java:409)
        at org.firebirdsql.jca.FBManagedConnection.<init>(FBManagedConnection.ja
va:105)
        at org.firebirdsql.jca.FBManagedConnectionFactory.createManagedConnectio
n(FBManagedConnectionFactory.java:509)
        at org.firebirdsql.jca.FBStandAloneConnectionManager.allocateConnection(
FBStandAloneConnectionManager.java:65)
        at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:118
)
        ... 4 more
import java.sql.*;
import java.util.Properties;

public class Connector {

    public static void main ( String[] args ) throws SQLException, ClassNotFoundException {
        Class.forName( "org.firebirdsql.jdbc.FBDriver" );

        System.out.println( "Starting orgaMax Connector Version 0.1" );
        System.out.println( "Connecting to the orgaMax Database" );

        Properties props = new Properties( );
        props.setProperty( "user", "OMODBCALLREAD" );
        props.setProperty( "password", "tKiulB3e" );
        props.setProperty( "encoding", "ISO8859_1" );

        Connection connection = DriverManager.getConnection(
                "jdbc:firebirdsql:127.0.0.1/5143:C:/ProgrammData/Deltra/orgaMAX/DB/DB1.fdb",
                props );

        System.out.println( "Successfully connected to the orgaMax Database." );

        spitOutAllTableRows( "BAS_ARTICLES", connection );
    }

    public static void spitOutAllTableRows ( String tableName, Connection conn ) {
        try {
            System.out.println( "current " + tableName + " is:" );
            try ( PreparedStatement selectStmt = conn.prepareStatement(
                    "SELECT * from " + tableName, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
                  ResultSet rs = selectStmt.executeQuery( ) ) {
                if ( !rs.isBeforeFirst( ) ) {
                    System.out.println( "no rows found" );
                } else {
                    System.out.println( "types:" );
                    for ( int i = 0; i < rs.getMetaData( ).getColumnCount( ); i++ ) {
                        System.out.print( rs.getMetaData( ).getColumnName( i + 1 ) + ":" + rs.getMetaData( ).getColumnTypeName( i + 1 ) + " " );
                    }
                    System.out.println( );
                    while ( rs.next( ) ) {
                        for ( int i = 1; i < rs.getMetaData( ).getColumnCount( ) + 1; i++ ) {
                            System.out.print( " " + rs.getMetaData( ).getColumnName( i ) + "=" + rs.getObject( i ) );
                        }
                        System.out.println( "" );
                    }
                }
            }
        } catch ( SQLException e ) {
            throw new RuntimeException( e );
        }
    }
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>at.orgamax.connector</groupId>
    <artifactId>connector</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.16</version>
        </dependency>

        <dependency>
            <groupId>org.firebirdsql.jdbc</groupId>
            <artifactId>jaybird-jdk18</artifactId>
            <version>2.2.12</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <archive>
                                <manifest>
                                    <mainClass>
                                       at.orgamax.connector.Connector
                                    </mainClass>
                                </manifest>
                            </archive>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

如果有人能在这里帮忙,我真的很高兴。

共有1个答案

丌官承
2023-03-14
Connection connection = DriverManager.getConnection(
                "jdbc:firebirdsql:127.0.0.1/5143:C:/ProgrammData/Deltra

计算单词“program”中的“m”个字母

您的ODBC信息显示一个字母。

您的Java源代码显示了两个字母。

 类似资料:
  • 查询数据库时出错。原因:org.springframework.JDBC.canNotgetJDBCConnectionException:未能获得JDBC连接;嵌套异常是java.sql.sqlexception:对文件“d:companydbprodatafile.fdb”进行“createFile(open)”操作时发生I/O错误;试图打开文件时出错;[SQLSTATE:08001,ISC错

  • PHP interbase中的Noob。 我正在做一个项目,我需要将数据保存在两个独立的数据库中。我使用默认的MySQL数据库,而另一个使用firebird。已下载此库 这是我的数据库。配置文件夹中的php。 需要多个数据库的函数 模型 我对create_purchaseorder函数没有问题,但是当我运行“save”函数时,它会给我这个错误 致命错误:调用未定义的函数ibase_connect(

  • 我是php的初学者,对于一个项目,我想把我和数据库连接起来,但问题是: 我需要4个变量: 当我这样做时: 有两个错误: 警告:mysqli::mysqli():php_network_getaddress:getaddrinfo失败:第21行/home/ubuntu/workspace/index.php中的名称或服务未知 而且 警告:mysqli::mysqli():(HY000/2002):p

  • 有人能帮帮我吗?在网上找不到有关此问题的任何内容。

  • 我有一个数据库。当我尝试使用库UCanAccess连接到它时: 连接时获取: 此类错误: 如果我只导出所需的表并连接到它,没有错误。但是我需要使用完整的数据库。 编辑 我删除了对DB中不存在文件的引用,但错误仍然存在:

  • 我目前正试图找到一个替代我的android应用程序后端。目前,我使用php servlets查询Mysql数据库。数据库(Mysql)托管在我学院的一台计算机上,所以我不能更改任何配置,因为我不是管理员。我只能编辑自己的表。 我试图使用以下代码创建一个java RESTful服务器: