01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: ProbeTable.java,v 1.2 2002/10/17 21:00:57 pierreg0 Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import java.sql.Connection;
14: import java.sql.DatabaseMetaData;
15: import java.sql.ResultSet;
16: import java.sql.SQLException;
17: import javax.jdo.JDODataStoreException;
18:
19: class ProbeTable extends BaseTable {
20: public ProbeTable(StoreManager storeMgr) {
21: super (storeMgr);
22:
23: name = new TableIdentifier(dba, "deleteMe"
24: + System.currentTimeMillis());
25: }
26:
27: public void initialize() {
28: assertIsUninitialized();
29:
30: dba.getMapping(newColumn(int.class, "unused"));
31:
32: state = TABLE_STATE_INITIALIZED;
33: }
34:
35: public String findSchemaName(Connection conn) throws SQLException {
36: String schemaName = null;
37: DatabaseMetaData dmd = conn.getMetaData();
38:
39: ResultSet rs = dmd.getTables(null, null, name
40: .getSQLIdentifier(), null);
41:
42: try {
43: if (!rs.next())
44: throw new JDODataStoreException(
45: "Cannot find probe table " + name);
46:
47: schemaName = rs.getString(2);
48: } finally {
49: rs.close();
50: }
51:
52: return schemaName;
53: }
54: }
|