当前位置: 首页>>代码示例>>Java>>正文


Java DriverManager.setLogWriter方法代码示例

本文整理汇总了Java中java.sql.DriverManager.setLogWriter方法的典型用法代码示例。如果您正苦于以下问题:Java DriverManager.setLogWriter方法的具体用法?Java DriverManager.setLogWriter怎么用?Java DriverManager.setLogWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.DriverManager的用法示例。


在下文中一共展示了DriverManager.setLogWriter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLogger

import java.sql.DriverManager; //导入方法依赖的package包/类
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()));
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:23,代码来源:LoggerTest.java

示例2: setLogToSystem

import java.sql.DriverManager; //导入方法依赖的package包/类
public static void setLogToSystem(boolean value) {

//#ifdef JAVA2FULL
        try {
            PrintWriter newPrintWriter = (value) ? new PrintWriter(System.out)
                                                 : null;

            DriverManager.setLogWriter(newPrintWriter);
        } catch (Exception e) {}

//#else
/*
        try {
            PrintStream newOutStream = (value) ? System.out
                                               : null;
            DriverManager.setLogStream(newOutStream);
        } catch (Exception e){}
*/

//#endif
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:22,代码来源:JavaSystem.java

示例3: setLogToSystem

import java.sql.DriverManager; //导入方法依赖的package包/类
public static void setLogToSystem(boolean value) {

//#ifdef JAVA1TARGET
/*
        try {
            PrintStream newOutStream = (value) ? System.out
                                               : null;
            DriverManager.setLogStream(newOutStream);
        } catch (Exception e){}
*/

//#else
        try {
            PrintWriter newPrintWriter = (value) ? new PrintWriter(System.out)
                                                 : null;

            DriverManager.setLogWriter(newPrintWriter);
        } catch (Exception e) {}

//#endif
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:JavaSystem.java

示例4: setLogToSystem

import java.sql.DriverManager; //导入方法依赖的package包/类
public static void setLogToSystem(boolean value) {

        try {
            PrintWriter newPrintWriter = (value) ? new PrintWriter(System.out)
                                                 : null;

            DriverManager.setLogWriter(newPrintWriter);
        } catch (Exception e) {}
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:10,代码来源:JavaSystem.java

示例5: tests18

import java.sql.DriverManager; //导入方法依赖的package包/类
/**
 * 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()));
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:32,代码来源:DriverManagerTests.java

示例6: setLogWriter

import java.sql.DriverManager; //导入方法依赖的package包/类
@Override
public void setLogWriter(PrintWriter out) throws SQLException {
    DriverManager.setLogWriter(out);
}
 
开发者ID:FelixKlauke,项目名称:prophecy,代码行数:5,代码来源:ProphecyDataSource.java

示例7: test4

import java.sql.DriverManager; //导入方法依赖的package包/类
@Test(expectedExceptions = AccessControlException.class)
public void test4() {
    setPolicy(new TestPolicy());
    DriverManager.setLogWriter(null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:DriverManagerPermissionsTests.java

示例8: test5

import java.sql.DriverManager; //导入方法依赖的package包/类
@Test
public void test5() {
    setPolicy(new TestPolicy("setLog"));
    DriverManager.setLogWriter(null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:DriverManagerPermissionsTests.java

示例9: test6

import java.sql.DriverManager; //导入方法依赖的package包/类
@Test
public void test6() {
    setPolicy(new TestPolicy("all"));
    DriverManager.setLogWriter(null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:DriverManagerPermissionsTests.java


注:本文中的java.sql.DriverManager.setLogWriter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。