Java Code Examples for java.sql.DriverManager#println()

The following examples show how to use java.sql.DriverManager#println() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DriverManagerTests.java    From openjdk-jdk9 with GNU General Public License v2.0 9 votes vote down vote up
/**
 * Create a PrintWriter and use to to send output via DriverManager.println
 * Validate that if you disable the writer, the output sent is not present
 */
@Test
public void tests18() throws Exception {
    CharArrayWriter cw = new CharArrayWriter();
    PrintWriter pw = new PrintWriter(cw);
    DriverManager.setLogWriter(pw);
    assertTrue(DriverManager.getLogWriter() == pw);

    DriverManager.println(results[0]);
    DriverManager.setLogWriter(null);
    assertTrue(DriverManager.getLogWriter() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogWriter(pw);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogWriter(null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    BufferedReader reader
            = new BufferedReader(new CharArrayReader(cw.toCharArray()));
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 2
Source File: DriverManagerTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintWriter and use to to send output via DriverManager.println
 * Validate that if you disable the writer, the output sent is not present
 */
@Test
public void tests18() throws Exception {
    CharArrayWriter cw = new CharArrayWriter();
    PrintWriter pw = new PrintWriter(cw);
    DriverManager.setLogWriter(pw);
    assertTrue(DriverManager.getLogWriter() == pw);

    DriverManager.println(results[0]);
    DriverManager.setLogWriter(null);
    assertTrue(DriverManager.getLogWriter() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogWriter(pw);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogWriter(null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    BufferedReader reader
            = new BufferedReader(new CharArrayReader(cw.toCharArray()));
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 3
Source File: DriverManagerTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintWriter and use to to send output via DriverManager.println
 * Validate that if you disable the writer, the output sent is not present
 */
@Test
public void tests18() throws Exception {
    CharArrayWriter cw = new CharArrayWriter();
    PrintWriter pw = new PrintWriter(cw);
    DriverManager.setLogWriter(pw);
    assertTrue(DriverManager.getLogWriter() == pw);

    DriverManager.println(results[0]);
    DriverManager.setLogWriter(null);
    assertTrue(DriverManager.getLogWriter() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogWriter(pw);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogWriter(null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    BufferedReader reader
            = new BufferedReader(new CharArrayReader(cw.toCharArray()));
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 4
Source File: DriverManagerTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintStream and use to send output via DriverManager.println
 * Validate that if you disable the stream, the output sent is not present
 */
@Test
public void tests17() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(os);
    DriverManager.setLogStream(ps);
    assertTrue(DriverManager.getLogStream() == ps);

    DriverManager.println(results[0]);
    DriverManager.setLogStream((PrintStream) null);
    assertTrue(DriverManager.getLogStream() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogStream(ps);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogStream((PrintStream) null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    InputStreamReader is
            = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
    BufferedReader reader = new BufferedReader(is);
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 5
Source File: DriverManagerTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintWriter and use to to send output via DriverManager.println
 * Validate that if you disable the writer, the output sent is not present
 */
@Test
public void tests18() throws Exception {
    CharArrayWriter cw = new CharArrayWriter();
    PrintWriter pw = new PrintWriter(cw);
    DriverManager.setLogWriter(pw);
    assertTrue(DriverManager.getLogWriter() == pw);

    DriverManager.println(results[0]);
    DriverManager.setLogWriter(null);
    assertTrue(DriverManager.getLogWriter() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogWriter(pw);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogWriter(null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    BufferedReader reader
            = new BufferedReader(new CharArrayReader(cw.toCharArray()));
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 6
Source File: DriverManagerTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintStream and use to send output via DriverManager.println
 * Validate that if you disable the stream, the output sent is not present
 */
@Test
public void tests17() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(os);
    DriverManager.setLogStream(ps);
    assertTrue(DriverManager.getLogStream() == ps);

    DriverManager.println(results[0]);
    DriverManager.setLogStream((PrintStream) null);
    assertTrue(DriverManager.getLogStream() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogStream(ps);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogStream((PrintStream) null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    InputStreamReader is
            = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
    BufferedReader reader = new BufferedReader(is);
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 7
Source File: DriverManagerTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintWriter and use to to send output via DriverManager.println
 * Validate that if you disable the writer, the output sent is not present
 */
@Test
public void tests18() throws Exception {
    CharArrayWriter cw = new CharArrayWriter();
    PrintWriter pw = new PrintWriter(cw);
    DriverManager.setLogWriter(pw);
    assertTrue(DriverManager.getLogWriter() == pw);

    DriverManager.println(results[0]);
    DriverManager.setLogWriter(null);
    assertTrue(DriverManager.getLogWriter() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogWriter(pw);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogWriter(null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    BufferedReader reader
            = new BufferedReader(new CharArrayReader(cw.toCharArray()));
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 8
Source File: DriverManagerTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintStream and use to send output via DriverManager.println
 * Validate that if you disable the stream, the output sent is not present
 */
@Test
public void tests17() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(os);
    DriverManager.setLogStream(ps);
    assertTrue(DriverManager.getLogStream() == ps);

    DriverManager.println(results[0]);
    DriverManager.setLogStream((PrintStream) null);
    assertTrue(DriverManager.getLogStream() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogStream(ps);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogStream((PrintStream) null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    InputStreamReader is
            = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
    BufferedReader reader = new BufferedReader(is);
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 9
Source File: DriverManagerTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintStream and use to send output via DriverManager.println
 * Validate that if you disable the stream, the output sent is not present
 */
@Test
public void tests17() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(os);
    DriverManager.setLogStream(ps);
    assertTrue(DriverManager.getLogStream() == ps);

    DriverManager.println(results[0]);
    DriverManager.setLogStream((PrintStream) null);
    assertTrue(DriverManager.getLogStream() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogStream(ps);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogStream((PrintStream) null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    InputStreamReader is
            = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
    BufferedReader reader = new BufferedReader(is);
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 10
Source File: DriverManagerTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintStream and use to send output via DriverManager.println
 * Validate that if you disable the stream, the output sent is not present
 */
@Test
public void tests17() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(os);
    DriverManager.setLogStream(ps);
    assertTrue(DriverManager.getLogStream() == ps);

    DriverManager.println(results[0]);
    DriverManager.setLogStream((PrintStream) null);
    assertTrue(DriverManager.getLogStream() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogStream(ps);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogStream((PrintStream) null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    InputStreamReader is
            = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
    BufferedReader reader = new BufferedReader(is);
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 11
Source File: DriverManagerTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintStream and use to send output via DriverManager.println
 * Validate that if you disable the stream, the output sent is not present
 */
@Test
public void tests17() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(os);
    DriverManager.setLogStream(ps);
    assertTrue(DriverManager.getLogStream() == ps);

    DriverManager.println(results[0]);
    DriverManager.setLogStream((PrintStream) null);
    assertTrue(DriverManager.getLogStream() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogStream(ps);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogStream((PrintStream) null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    InputStreamReader is
            = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
    BufferedReader reader = new BufferedReader(is);
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 12
Source File: DriverManagerTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintWriter and use to to send output via DriverManager.println
 * Validate that if you disable the writer, the output sent is not present
 */
@Test
public void tests18() throws Exception {
    CharArrayWriter cw = new CharArrayWriter();
    PrintWriter pw = new PrintWriter(cw);
    DriverManager.setLogWriter(pw);
    assertTrue(DriverManager.getLogWriter() == pw);

    DriverManager.println(results[0]);
    DriverManager.setLogWriter(null);
    assertTrue(DriverManager.getLogWriter() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogWriter(pw);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogWriter(null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    BufferedReader reader
            = new BufferedReader(new CharArrayReader(cw.toCharArray()));
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 13
Source File: DriverManagerTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintStream and use to send output via DriverManager.println
 * Validate that if you disable the stream, the output sent is not present
 */
@Test
public void tests17() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(os);
    DriverManager.setLogStream(ps);
    assertTrue(DriverManager.getLogStream() == ps);

    DriverManager.println(results[0]);
    DriverManager.setLogStream((PrintStream) null);
    assertTrue(DriverManager.getLogStream() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogStream(ps);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogStream((PrintStream) null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    InputStreamReader is
            = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
    BufferedReader reader = new BufferedReader(is);
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 14
Source File: DriverManagerTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintWriter and use to to send output via DriverManager.println
 * Validate that if you disable the writer, the output sent is not present
 */
@Test
public void tests18() throws Exception {
    CharArrayWriter cw = new CharArrayWriter();
    PrintWriter pw = new PrintWriter(cw);
    DriverManager.setLogWriter(pw);
    assertTrue(DriverManager.getLogWriter() == pw);

    DriverManager.println(results[0]);
    DriverManager.setLogWriter(null);
    assertTrue(DriverManager.getLogWriter() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogWriter(pw);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogWriter(null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    BufferedReader reader
            = new BufferedReader(new CharArrayReader(cw.toCharArray()));
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 15
Source File: DriverManagerTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintStream and use to send output via DriverManager.println
 * Validate that if you disable the stream, the output sent is not present
 */
@Test
public void tests17() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(os);
    DriverManager.setLogStream(ps);
    assertTrue(DriverManager.getLogStream() == ps);

    DriverManager.println(results[0]);
    DriverManager.setLogStream((PrintStream) null);
    assertTrue(DriverManager.getLogStream() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogStream(ps);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogStream((PrintStream) null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    InputStreamReader is
            = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
    BufferedReader reader = new BufferedReader(is);
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 16
Source File: DriverManagerTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintWriter and use to to send output via DriverManager.println
 * Validate that if you disable the writer, the output sent is not present
 */
@Test
public void tests18() throws Exception {
    CharArrayWriter cw = new CharArrayWriter();
    PrintWriter pw = new PrintWriter(cw);
    DriverManager.setLogWriter(pw);
    assertTrue(DriverManager.getLogWriter() == pw);

    DriverManager.println(results[0]);
    DriverManager.setLogWriter(null);
    assertTrue(DriverManager.getLogWriter() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogWriter(pw);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogWriter(null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    BufferedReader reader
            = new BufferedReader(new CharArrayReader(cw.toCharArray()));
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 17
Source File: DriverManagerTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintStream and use to send output via DriverManager.println
 * Validate that if you disable the stream, the output sent is not present
 */
@Test
public void tests17() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(os);
    DriverManager.setLogStream(ps);
    assertTrue(DriverManager.getLogStream() == ps);

    DriverManager.println(results[0]);
    DriverManager.setLogStream((PrintStream) null);
    assertTrue(DriverManager.getLogStream() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogStream(ps);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogStream((PrintStream) null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    InputStreamReader is
            = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
    BufferedReader reader = new BufferedReader(is);
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 18
Source File: DriverManagerTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a PrintWriter and use to to send output via DriverManager.println
 * Validate that if you disable the writer, the output sent is not present
 */
@Test
public void tests18() throws Exception {
    CharArrayWriter cw = new CharArrayWriter();
    PrintWriter pw = new PrintWriter(cw);
    DriverManager.setLogWriter(pw);
    assertTrue(DriverManager.getLogWriter() == pw);

    DriverManager.println(results[0]);
    DriverManager.setLogWriter(null);
    assertTrue(DriverManager.getLogWriter() == null);
    DriverManager.println(noOutput);
    DriverManager.setLogWriter(pw);
    DriverManager.println(results[1]);
    DriverManager.println(results[2]);
    DriverManager.println(results[3]);
    DriverManager.setLogWriter(null);
    DriverManager.println(noOutput);

    /*
     * Check we do not get the output when the stream is disabled
     */
    BufferedReader reader
            = new BufferedReader(new CharArrayReader(cw.toCharArray()));
    for (String result : results) {
        assertTrue(result.equals(reader.readLine()));
    }
}
 
Example 19
Source File: Logger.java    From clickhouse-jdbc with Apache License 2.0 4 votes vote down vote up
public synchronized void log(String message, Level level) {
    if (level.intValue() >= currentLevel.intValue()) {
        String str = String.format("%s <%s> %s: %s", DATE_FORMAT.format(new Date()), level.getName(), key, message);
        DriverManager.println(str);
    }
}