当我运行一个应该返回确切行的sql语句时,sqlplus打印列名称多次?为什么?
我想使用java来读取weblogic日志文件,而weblogic正在将日志写入其中(缓冲),但我只想读取内容,当我开始阅读它时.
我怎样才能做到这一点 ?
public class DemoReader implements Runnable{
public void run() {
File f = new File ("c:\\test.txt");
long length = f.length();
long readedBytes = 0;
System.out.println(length);
try {
BufferedReader fr = new BufferedReader(new FileReader(f));
String line = "";
while((line = fr.readLine()) != null && readedBytes < length){
readedBytes += line.getBytes().length;
if(readedBytes > length){
break;
}else{
System.out.println(line);
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我在servlet上下文监听器中启动h2数据库:
public void contextInitialized(ServletContextEvent sce) {
org.h2.Driver.load();
String apprealPath = sce.getServletContext().getRealPath("\\");
String h2Url = "jdbc:h2:file:" + apprealPath + "DB\\cdb;AUTO_SERVER=true";
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);
logger.debug("h2 url : " + h2Url);
try {
conn = DriverManager.getConnection(h2Url, "sa", "sa");
} catch (SQLException e) {
e.printStackTrace();
}
logger.debug("h2 database started in embedded mode");
sce.getServletContext().setAttribute("connection", conn);
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用dbvisualizer使用以下url连接到h2:
jdbc:h2:tcp://localhost/~/cdb
Run Code Online (Sandbox Code Playgroud)
但得到这些错误消息:
An error occurred while establishing the connection:
Type: org.h2.jdbc.JdbcSQLException Error Code: 90067 SQL State: 90067
Message:
Connection is broken: "Connection refused: connect" [90067-148] …Run Code Online (Sandbox Code Playgroud) 当错误发生时,我发现很难跟踪大型和混合(会话)日志文件中的问题?所以,我想为每个用户创建一个日志文件,但我担心如果我这样做会对性能产生很大影响.有超过1000个用户,从现在开始,最多在线用户数低于100
对不起我的英语,我希望你们能理解我在说什么......