本文整理汇总了Java中java.sql.DriverManager.println方法的典型用法代码示例。如果您正苦于以下问题:Java DriverManager.println方法的具体用法?Java DriverManager.println怎么用?Java DriverManager.println使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.DriverManager
的用法示例。
在下文中一共展示了DriverManager.println方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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()));
}
}