Search in sources :

Example 1 with RDBMSStoreData

use of org.datanucleus.store.rdbms.RDBMSStoreData in project datanucleus-rdbms by datanucleus.

the class SchemaAutoStarter method addClass.

/**
 * Method to add a class to the supported list.
 * @param data Data for the class to add.
 */
public void addClass(StoreData data) {
    // We only support MappedStoreData
    RDBMSStoreData tableData = (RDBMSStoreData) data;
    assertIsOpen();
    try {
        schemaTable.addClass(tableData, mconn);
    } catch (SQLException sqe2) {
        String msg = Localiser.msg("049003", data.getName(), sqe2);
        NucleusLogger.DATASTORE_SCHEMA.error(msg);
        throw new NucleusDataStoreException(msg, sqe2);
    }
}
Also used : NucleusDataStoreException(org.datanucleus.exceptions.NucleusDataStoreException) SQLException(java.sql.SQLException) RDBMSStoreData(org.datanucleus.store.rdbms.RDBMSStoreData)

Example 2 with RDBMSStoreData

use of org.datanucleus.store.rdbms.RDBMSStoreData in project datanucleus-rdbms by datanucleus.

the class SchemaTable method getAllClasses.

/**
 * Accessor for the classes already supported by this Schema Table.
 * @param conn Connection for this datastore.
 * @return The HashSet of class names (StoreData)
 * @throws SQLException Thrown when an error occurs in the process.
 */
public HashSet getAllClasses(ManagedConnection conn) throws SQLException {
    HashSet schema_data = new HashSet();
    if (storeMgr.getDdlWriter() != null && !tableExists((Connection) conn.getConnection())) {
        // do not query non-existing schema table when DDL is only written to file
        return schema_data;
    }
    SQLController sqlControl = storeMgr.getSQLController();
    PreparedStatement ps = sqlControl.getStatementForQuery(conn, fetchAllStmt);
    try {
        ResultSet rs = sqlControl.executeStatementQuery(null, conn, fetchAllStmt, ps);
        try {
            while (rs.next()) {
                StoreData data = new RDBMSStoreData(rs.getString(1), rs.getString(2), rs.getString(4).equals("1") ? true : false, rs.getString(3).equals("FCO") ? StoreData.Type.FCO : StoreData.Type.SCO, rs.getString(6));
                schema_data.add(data);
            }
        } finally {
            rs.close();
        }
    } finally {
        sqlControl.closeStatement(conn, ps);
    }
    return schema_data;
}
Also used : RDBMSStoreData(org.datanucleus.store.rdbms.RDBMSStoreData) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) HashSet(java.util.HashSet) SQLController(org.datanucleus.store.rdbms.SQLController) RDBMSStoreData(org.datanucleus.store.rdbms.RDBMSStoreData) StoreData(org.datanucleus.store.StoreData)

Aggregations

RDBMSStoreData (org.datanucleus.store.rdbms.RDBMSStoreData)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1 NucleusDataStoreException (org.datanucleus.exceptions.NucleusDataStoreException)1 StoreData (org.datanucleus.store.StoreData)1 SQLController (org.datanucleus.store.rdbms.SQLController)1