本文整理汇总了Java中java.sql.DriverManager.setLogStream方法的典型用法代码示例。如果您正苦于以下问题:Java DriverManager.setLogStream方法的具体用法?Java DriverManager.setLogStream怎么用?Java DriverManager.setLogStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.DriverManager
的用法示例。
在下文中一共展示了DriverManager.setLogStream方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tests17
import java.sql.DriverManager; //导入方法依赖的package包/类
/**
* 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()));
}
}
示例2: test
import java.sql.DriverManager; //导入方法依赖的package包/类
@Test(expectedExceptions = AccessControlException.class)
public void test() {
setPolicy(new TestPolicy());
DriverManager.setLogStream(null);
}
示例3: test1
import java.sql.DriverManager; //导入方法依赖的package包/类
@Test
public void test1() {
Policy.setPolicy(new TestPolicy("setLog"));
DriverManager.setLogStream(null);
}
示例4: test2
import java.sql.DriverManager; //导入方法依赖的package包/类
@Test
public void test2() {
setPolicy(new TestPolicy("all"));
DriverManager.setLogStream(null);
}