Package org.apache.derby.client.am

Examples of org.apache.derby.client.am.LogWriter


        // Jdbc 2 connections will write driver trace info on a
        // datasource-wide basis using the jdbc 2 data source log writer.
        // This log writer may be narrowed to the connection-level
        // This log writer will be passed to the agent constructor.

        LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_sds");
        updateDataSourceValues(tokenizeAttributes(connectionAttributes, null));
        return new NetConnection((NetLogWriter) dncLogWriter, user, password, this, -1, false);
    }
View Full Code Here


    // ---------------------------interface methods-------------------------------

    // Attempt to establish a physical database connection that can be used as a pooled connection.
    public PooledConnection getPooledConnection() throws SQLException {
        LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_cpds");
        if (dncLogWriter != null) {
            dncLogWriter.traceEntry(this, "getPooledConnection");
        }
        PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, user, password);
        if (dncLogWriter != null) {
            dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
        }
        return pooledConnection;
    }
View Full Code Here

        return pooledConnection;
    }

    // Standard method that establishes the initial physical connection using CPDS properties.
    public PooledConnection getPooledConnection(String user, String password) throws SQLException {
        LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_cpds");
        if (dncLogWriter != null) {
            dncLogWriter.traceEntry(this, "getPooledConnection", user, "<escaped>");
        }
        PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, user, password);
        if (dncLogWriter != null) {
            dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
        }
        return pooledConnection;
    }
View Full Code Here

        return pooledConnection;
    }

    //  method that establishes the initial physical connection using DS properties instead of CPDS properties.
    public PooledConnection getPooledConnection(ClientDataSource ds, String user, String password) throws SQLException {
        LogWriter dncLogWriter = ds.computeDncLogWriterForNewConnection("_cpds");
        if (dncLogWriter != null) {
            dncLogWriter.traceEntry(this, "getPooledConnection", ds, user, "<escaped>");
        }
        PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, ds, user, password);
        if (dncLogWriter != null) {
            dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
        }
        return pooledConnection;
    }
View Full Code Here

                            break; // found the property field, so break the while loop.
                        } catch (NoSuchFieldException nsfe) {
                            // property field is not found at current level of class, so continue to super class.
                            clz = clz.getSuperclass();
                            if (clz == Object.class) {
                                throw new SqlException(new LogWriter(logWriter, traceLevel), "bug check: corresponding property field does not exist");
                            }
                            continue;
                        }
                    }

                    if (!Modifier.isTransient(propertyField.getModifiers())) {
                        // if the property is not transient:
                        // set the property.
                        address = ref.get(propertyKey);
                        if (address != null) {
                            propertyField.setAccessible(true);
                            String type = propertyField.getType().toString();
                            if (type.equals("boolean")) {
                                boolean value = ((String) address.getContent()).equalsIgnoreCase("true");
                                propertyField.setBoolean(this, value);
                            } else if (type.equals("byte")) {
                                byte value = Byte.parseByte((String) address.getContent());
                                propertyField.setByte(this, value);
                            } else if (type.equals("short")) {
                                short value = Short.parseShort((String) address.getContent());
                                propertyField.setShort(this, value);
                            } else if (type.equals("int")) {
                                int value = Integer.parseInt((String) address.getContent());
                                propertyField.setInt(this, value);
                            } else if (type.equals("long")) {
                                long value = Long.parseLong((String) address.getContent());
                                propertyField.setLong(this, value);
                            } else if (type.equals("float")) {
                                float value = Float.parseFloat((String) address.getContent());
                                propertyField.setFloat(this, value);
                            } else if (type.equals("double")) {
                                double value = Double.parseDouble((String) address.getContent());
                                propertyField.setDouble(this, value);
                            } else if (type.equals("char")) {
                                char value = ((String) address.getContent()).charAt(0);
                                propertyField.setChar(this, value);
                            } else {
                                propertyField.set(this, address.getContent());
                            }
                        }
                    }
                } catch (IllegalAccessException e) {
                    throw new SqlException(new LogWriter(this.logWriter, this.traceLevel), "bug check: property cannot be accessed");
                }
            }
        }
    }
View Full Code Here

                            break; // found the property field, so break the while loop.
                        } catch (NoSuchFieldException nsfe) {
                            // property field is not found at current level of class, so continue to super class.
                            clz = clz.getSuperclass();
                            if (clz == Object.class) {
                                throw new SqlException(new LogWriter(logWriter, traceLevel), "bug check: corresponding property field does not exist");
                            }
                            continue;
                        }
                    }

                    if (!Modifier.isTransient(propertyField.getModifiers())) {
                        // if the property is not transient:
                        // get the property.
                        propertyField.setAccessible(true);
                        Object propertyObj = propertyField.get(this);
                        String property = String.valueOf(propertyObj); // don't use toString becuase it may be null.
                        if ("password".equals(propertyKey)) {
                            StringBuffer sb = new StringBuffer(property);
                            for (int j = 0; j < property.length(); j++) {
                                sb.setCharAt(j, '*');
                            }
                            property = sb.toString();
                        }
                        // add into prperties.
                        properties.setProperty(propertyKey, property);
                    }
                } catch (IllegalAccessException e) {
                    throw new SqlException(new LogWriter(this.logWriter, this.traceLevel), "bug check: property cannot be accessed");
                }
            }
        }

        return properties;
View Full Code Here

    // If neither traceFile, nor logWriter, nor traceDirectory are set, then null is returned.
    static public LogWriter computeDncLogWriterForNewConnection(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, int traceLevel, String logWriterInUseSuffix, int traceFileSuffixIndex) throws SqlException {
        int globaltraceFileSuffixIndex = Configuration.traceFileSuffixIndex__++;

        // compute regular dnc log writer if there is any
        LogWriter dncLogWriter = computeDncLogWriter(logWriter, traceDirectory, traceFile, traceFileAppend, logWriterInUseSuffix, traceFileSuffixIndex, traceLevel);
        if (dncLogWriter != null) {
            return dncLogWriter;
        }
        // compute global default dnc log writer if there is any
        dncLogWriter = computeDncLogWriter(null, Configuration.traceDirectory__, Configuration.traceFile__, Configuration.traceFileAppend__, "_global", globaltraceFileSuffixIndex, Configuration.traceLevel__);
View Full Code Here

        PrintWriter printWriter = computePrintWriter(logWriter, traceDirectory, traceFile, traceFileAppend, logWriterInUseSuffix, traceFileSuffixIndex);
        if (printWriter == null) {
            return null;
        }

        LogWriter dncLogWriter = new NetLogWriter(printWriter, traceLevel);
        if (printWriter != logWriter && traceDirectory != null)
        // When printWriter is an internal trace file and
        // traceDirectory is not null, each connection has
        // its own trace file and the trace file is not cached,
        // so we can close it when DNC log writer is closed.
View Full Code Here

        PrintWriter printWriter = computePrintWriter(logWriter, traceDirectory, traceFile, traceFileAppend, logWriterInUseSuffix, traceFileSuffixIndex);
        if (printWriter == null) {
            return null;
        }

        LogWriter dncLogWriter = connection.agent_.newLogWriter_(printWriter, traceLevel);
        if (printWriter != logWriter && traceDirectory != null)
        // When printWriter is an internal trace file and
        // traceDirectory is not null, each connection has
        // its own trace file and the trace file is not cached,
        // so we can close it when DNC log writer is closed.
View Full Code Here

        ccsidManager = new Utf8CcsidManager();

        // Set up a dummy Agent since many of the methods require one for
        // generating exceptions.
        PrintWriter pw = new PrintWriter(new TestNullOutputStream());
        agent = new NetAgent(null, new LogWriter(pw, 0));
    }
View Full Code Here

TOP

Related Classes of org.apache.derby.client.am.LogWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.