javahibernatepervasivepervasive-sql

Pervasive SQL Java database name


I also tried the standard Java connection using this answer: Creating a Java Connector for Pervasive PSQL

The main problem here is that it works with Demodata, but the name of the database I need to use ° in the name: 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). I already have three files: jpscs.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 supports Pervasive and I'm not sure if possible to configure custom 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). 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:

<?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>

Solution

  • In the end I used C# with this code:

    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 the JDBC driver on Java that does not allow special characters like ° in the database name. I cannot change the database name, so my only way is to use C#.