public class SerializeDataSources
extends java.lang.Object
Four entities are written to the stream:
Both embedded and client data sources are attempted serialized, and the data source class names are obtained from a predefined list. If another data source implementation is added to Derby, its class name must be added to the list if this class is supposed to serialize it and write it to file.
Existing files are overwritten, and the file name is constructed like this: <ClassName>-<modifiedVersionString>.ser The version string is modified by replacing punctuation marks with underscores.
Modifier and Type | Field and Description |
---|---|
private static java.lang.String[] |
KNOWN_CLIENT_DATA_SOURCES
List of known data sources in the client driver.
|
private static java.lang.String[] |
KNOWN_EMBEDDED_DATA_SOURCES
List of known data sources in the embedded driver.
|
Constructor and Description |
---|
SerializeDataSources() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] args)
Serializes and writes a number of Derby data sources to disk, or
attempts to read information from existing files.
|
private static boolean |
printInfoFromSerializedFile(java.lang.String fileName)
Attempts to read information from a file assumed to contain a
serialized data source.
|
private static int |
serializeDataSources(java.lang.String versionString,
java.lang.String buildNumber,
java.lang.String[] dataSourceClasses)
Serialize and write data sources to file.
|
private static final java.lang.String[] KNOWN_EMBEDDED_DATA_SOURCES
private static final java.lang.String[] KNOWN_CLIENT_DATA_SOURCES
private static int serializeDataSources(java.lang.String versionString, java.lang.String buildNumber, java.lang.String[] dataSourceClasses) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.io.IOException, javax.naming.NamingException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
versionString
- Derby version string (i.e. 10.3.2.1)buildNumber
- Derby build number (svn)dataSourceClasses
- list of data source class namesjava.lang.ClassNotFoundException
- required class is not on the classpathjava.lang.InstantiationException
- if instantiating data source class failsjava.lang.IllegalAccessException
- if instantiating data source class failsjava.io.IOException
- if writing to file failsjavax.naming.NamingException
- if creating a naming reference for the data
source failsjava.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
private static boolean printInfoFromSerializedFile(java.lang.String fileName)
All information is printed to the console.
fileName
- the name of the file to read fromtrue
if the file was read successfully, false
if
something went wrong.public static void main(java.lang.String[] args) throws java.lang.Exception
args
- arguments from the command line. If there are no arguments,
the program will write data sources to file. Otherwise all
arguments are assumed to be file names of files to read.java.lang.Exception
- if something goes wrongApache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.