Java Code Examples for java.sql.DriverManager#setLogWriter()
The following examples show how to use
java.sql.DriverManager#setLogWriter() .
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: LoggerTest.java From spanner-jdbc with MIT License | 6 votes |
private void testLogger(Integer connectionId, String expectedConnectionId, Throwable t) { StringWriter writer = new StringWriter(); PrintWriter out = new PrintWriter(writer); DriverManager.setLogWriter(out); Logger logger = connectionId == null ? new Logger() : new Logger(connectionId); logger.setLogLevel(CloudSpannerDriver.INFO); logger.info(INFO_STRING); logger.debug(DEBUG_STRING); assertTrue(writer.toString().contains(INFO_STRING)); assertFalse(writer.toString().contains(DEBUG_STRING)); logger.setLogLevel(CloudSpannerDriver.DEBUG); logger.debug(DEBUG_STRING); assertTrue(writer.toString().contains(DEBUG_STRING)); assertTrue(writer.toString().contains(expectedConnectionId)); logger.info(THROWABLE_STRING, t); assertTrue(writer.toString().contains(THROWABLE_STRING)); if (t == null) assertFalse(writer.toString().contains("Exception")); else assertTrue(writer.toString().contains(t.getMessage())); }
Example 2
Source File: DriverManagerTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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 |
/** * 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 openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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 5
Source File: LoggerPrintWriterJdbcH2Test.java From logging-log4j2 with Apache License 2.0 | 5 votes |
@Test public void testDriverManager_setLogWriter() throws SQLException { DriverManager.setLogWriter(createLoggerPrintWriter()); // DriverManager.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out))); try (final Connection conn = this.newConnection()) { conn.rollback(); } finally { DriverManager.setLogWriter(null); } Assert.assertTrue(this.getListAppender().getMessages().size() > 0); }
Example 6
Source File: DriverManagerTests.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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 7
Source File: DriverManagerPermissionsTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test6() { setPolicy(new TestPolicy("all")); DriverManager.setLogWriter(null); }
Example 8
Source File: DriverManagerPermissionsTests.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test6() { setPolicy(new TestPolicy("all")); DriverManager.setLogWriter(null); }
Example 9
Source File: DriverManagerPermissionsTests.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = AccessControlException.class) public void test4() { setPolicy(new TestPolicy()); DriverManager.setLogWriter(null); }
Example 10
Source File: DriverManagerPermissionsTests.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test public void test6() { setPolicy(new TestPolicy("all")); DriverManager.setLogWriter(null); }
Example 11
Source File: DriverManagerPermissionsTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = AccessControlException.class) public void test4() { setPolicy(new TestPolicy()); DriverManager.setLogWriter(null); }
Example 12
Source File: DriverManagerPermissionsTests.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = AccessControlException.class) public void test4() { setPolicy(new TestPolicy()); DriverManager.setLogWriter(null); }
Example 13
Source File: DriverManagerPermissionsTests.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test public void test5() { setPolicy(new TestPolicy("setLog")); DriverManager.setLogWriter(null); }
Example 14
Source File: DriverManagerPermissionsTests.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test public void test6() { setPolicy(new TestPolicy("all")); DriverManager.setLogWriter(null); }
Example 15
Source File: DriverManagerPermissionsTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Test public void test6() { setPolicy(new TestPolicy("all")); DriverManager.setLogWriter(null); }
Example 16
Source File: DriverManagerPermissionsTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test5() { setPolicy(new TestPolicy("setLog")); DriverManager.setLogWriter(null); }
Example 17
Source File: DriverManagerPermissionsTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test public void test5() { setPolicy(new TestPolicy("setLog")); DriverManager.setLogWriter(null); }
Example 18
Source File: DriverManagerPermissionsTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Test public void test5() { setPolicy(new TestPolicy("setLog")); DriverManager.setLogWriter(null); }
Example 19
Source File: DriverManagerPermissionsTests.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test5() { setPolicy(new TestPolicy("setLog")); DriverManager.setLogWriter(null); }
Example 20
Source File: SimpleDataSource.java From sqlhelper with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void setLogWriter(PrintWriter out) throws SQLException { DriverManager.setLogWriter(out); }