KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdbc > sql > conv > NotSupportedConverter


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdbc.sql.conv;
13
14 import com.versant.core.jdbc.JdbcConverter;
15 import com.versant.core.jdbc.JdbcTypeRegistry;
16 import com.versant.core.jdbc.metadata.JdbcColumn;
17
18 import java.sql.PreparedStatement JavaDoc;
19 import java.sql.SQLException JavaDoc;
20 import java.sql.ResultSet JavaDoc;
21
22 import javax.jdo.JDOFatalDataStoreException; //todo: appears only in throws-clause
23

24 import com.versant.core.common.BindingSupportImpl;
25
26 /**
27  * This converter throws a JDODatastoreException with a "not supported"
28  * message if its methods are invoked. This is used for databases that
29  * do not support certain data types e.g Informix SE does not support BLOBS
30  * and TEXT columns at all.
31  * @keep-all
32  */

33 public class NotSupportedConverter extends JdbcConverterBase {
34
35     public static class Factory extends NoArgJdbcConverterFactory {
36
37         private NotSupportedConverter converter;
38
39         /**
40          * Create a converter for col using props as parameters. Return null if
41          * no converter is required.
42          */

43         public JdbcConverter createJdbcConverter(JdbcColumn col, Object JavaDoc args,
44                 JdbcTypeRegistry jdbcTypeRegistry) {
45             if (converter == null) converter = new NotSupportedConverter();
46             return converter;
47         }
48
49     }
50
51     /**
52      * Get the value of col from rs at position index.
53      * @exception SQLException on SQL errors
54      * @exception JDOFatalDataStoreException if the ResultSet value is invalid
55      */

56     public Object JavaDoc get(ResultSet JavaDoc rs, int index, JdbcColumn col)
57             throws SQLException JavaDoc, JDOFatalDataStoreException {
58         throw BindingSupportImpl.getInstance().fatalDatastore("Datatype not supported by database");
59     }
60
61     /**
62      * Set parameter index on ps to value (for col).
63      * @exception SQLException on SQL errors
64      * @exception JDOFatalDataStoreException if value is invalid
65      */

66     public void set(PreparedStatement JavaDoc ps, int index, JdbcColumn col, Object JavaDoc value)
67             throws SQLException JavaDoc, JDOFatalDataStoreException {
68         throw BindingSupportImpl.getInstance().fatalDatastore("Datatype not supported by database");
69     }
70
71     /**
72      * Get the type of our expected value objects (e.g. java.util.Locale
73      * for a converter for Locale's).
74      */

75     public Class JavaDoc getValueType() {
76         return byte[].class;
77     }
78
79 }
80
81
Popular Tags