本文整理汇总了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()));
}
示例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
}
示例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
}
示例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) {}
}
示例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()));
}
}
示例6: setLogWriter
import java.sql.DriverManager; //导入方法依赖的package包/类
@Override
public void setLogWriter(PrintWriter out) throws SQLException {
DriverManager.setLogWriter(out);
}
示例7: test4
import java.sql.DriverManager; //导入方法依赖的package包/类
@Test(expectedExceptions = AccessControlException.class)
public void test4() {
setPolicy(new TestPolicy());
DriverManager.setLogWriter(null);
}
示例8: test5
import java.sql.DriverManager; //导入方法依赖的package包/类
@Test
public void test5() {
setPolicy(new TestPolicy("setLog"));
DriverManager.setLogWriter(null);
}
示例9: test6
import java.sql.DriverManager; //导入方法依赖的package包/类
@Test
public void test6() {
setPolicy(new TestPolicy("all"));
DriverManager.setLogWriter(null);
}