简体   繁体   English

普遍的SQL Java数据库名称

[英]Pervasive SQL Java Database Name

EDIT: I also tried the standard java connection using this answer: Creating Java Connector for pervasive 编辑:我也尝试使用此答案的标准Java连接: 为普及创建Java连接器

the main problem here is that it works with Demodata, but the name of the database I need to use use ° in the name: GESCOOP°2018 这里的主要问题是它可以与Demodata一起使用,但是我需要使用的数据库名称中使用°:GESCOOP°2018

I'm not sure that is the problem but I know that I only get this error: 我不确定这是问题所在,但我知道我只会收到此错误:

SQLException: [LNA][PSQL][SQL Engine][Data Record Manager]Cannot locate the named database you specified(Btrieve Error 2301)

for database with ° in the name. 名称中带有°的数据库。

Original question: 原始问题:

I need to use a Pervasive ODBC database with Hibernate (if possible, if not I need to use it inside java). 我需要在Hibernate中使用Pervasive ODBC数据库(如果可能的话,如果没有的话,我需要在Java内部使用它)。 I already got 3 files: jpscs.jar pvjdbc2.jar pvjdbc2x.jar that should be the JDBC drivers for pervasive DB but I don't know how to create an hibernate config file with this dialect (I'm not sure hibernate support pervasive and I'm not sure if possible to configure custom sql db). 我已经有了3个文件:jpscs.jar pvjdbc2.jar pvjdbc2x.jar应该是普及数据库的JDBC驱动程序,但是我不知道如何用这种方言创建一个休眠配置文件(我不确定休眠是否支持普及和我不确定是否可以配置自定义sql db)。

I was just able to configure a Pervasive 32-bit ODBC Client DNS setup (with windows configure data source on control panel) with a simple Server Name (no account or password). 我只是能够使用简单的服务器名称(没有帐户或密码)配置Pervasive 32位ODBC客户端DNS设置(使用Windows在控制面板上配置数据源)。 And the connection test is successful but I don't know how to view tables and data of this db. 连接测试成功,但是我不知道如何查看该数据库的表和数据。

Current hibernate config file hibernate.cfg.xml: 当前的休眠配置文件hibernate.cfg.xml:

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM 
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>

    <property name = "hibernate.dialect">
     org.hibernate.dialect.
    </property>

    <property name = "hibernate.connection.driver_class">
     com.pervasive.jdbc.v2.Driver
    </property>

    <!-- Assume test is the database name -->

    <property name = "hibernate.connection.url">
     GBJOB09.GBJOB.LOCAL/GESCOOP*2018
    </property>

    <!-- List of XML mapping files -->
    <!-- mapping resource = "Employee.hbm.xml"/ -->

 </session-factory>
</hibernate-configuration>

In the end I used C# with this code: 最后,我将C#与以下代码结合使用:

string conn = "Provider=PervasiveOLEDB;  Data Source=gescoop°2018;Location=<url>";
string queryString = "select * from TAB_UTENTI";

try
{
    using (OleDbConnection connection = new OleDbConnection(conn))
    {
        OleDbCommand command = new OleDbCommand(queryString, connection);
        connection.Open();
        OleDbDataReader reader = command.ExecuteReader();

        while (reader.Read())
        {
            Debug.WriteLine(reader.GetValue(0).ToString() + "  " +
                reader.GetValue(1).ToString() + "  " +
                ...
                reader.GetValue(47).ToString() + "  ");
        }
        reader.Close();
    }
}
catch (Exception ex)
{
    Debug.WriteLine("Failed to connect to data source " + ex.Message);
}

I think there is some limitation with jdbc driver on java that does not allow special characters like ° in the database name. 我认为Java上的jdbc驱动程序存在一些限制,不允许在数据库名称中使用特殊字符,例如°。 I cannot change the database name so my only way is to use C#. 我无法更改数据库名称,所以我唯一的方法是使用C#。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM