javalstat的简单介绍

博主:adminadmin 2023-01-27 21:57:06 611

本篇文章给大家谈谈javalstat,以及对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

tomcat以tomcat用户启动jsvc启动异常问题?

用来启动tomcat,在linux下面使用

在linux上以服务的方式启动java程序

1.安装jsvc

在tomcat的bin目录下有一个jsvc.tar.gz的文件,进入tomcat的bin目录下

#tar xvfz jsvc.tar.gz

#cd jsvc-src

#sh support/buildconf.sh

#chmod 755 configure

#./configure --with-java=/usr/local/java (改成你的JDK的位置)

#make

2.编写服务启动类

package com.sohu.jsvc.test;

public class TestJsvc {

public static void main(String args[]) {

System.out.println("execute main method!");

}

public void init() throws Exception {

System.out.println("execute init method!");

}

public void init(String[] args) throws Exception{

System.out.println("execute init(args) method");

}

public void start() throws Exception {

System.out.println("execute start method!");

}

public void stop() throws Exception {

System.out.println("execute stop method!");

}

public void destroy() throws Exception{

System.out.println("execute destroy method!");

}

}

main方法可以去掉,但是init(String[] args),start(),stop(),destroy()方法不能少,服务在启动时会先调用init(String[] args)方法

然后调用start()方法,在服务停止是会首先调用stop()方法,然后调用destroy() 方法.

3.把这个类打包成testjsvc.jar 放到/test目录下

4.编写启动服务的脚本 myjsvc

#!/bin/sh

# myjsvc This shell script takes care of starting and stopping

#

# chkconfig: - 60 50

# description: tlstat stat is a stat data daemon.

# processname: myjsvc

# Source function library.

. /etc/rc.d/init.d/functions

RETVAL=0

prog="MYJSVC"

# jdk的安装目录

JAVA_HOME=/usr/java/jdk1.5.0_15

#应用程序的目录

MYJSVC_HOME=/test

#jsvc所在的目录

DAEMON_HOME=/usr/local/tomcat5/bin/jsvc-src

#用户

MYJSVC_USER=root

# for multi instances adapt those lines.

TMP_DIR=/var/tmp

PID_FILE=/var/run/tlstat.pid

#程序运行是所需的jar包,commons-daemon.jar是不能少的

CLASSPATH=/test/testjsvc.jar:/usr/local/tomcat5/bin/commons-daemon.jar:

case "$1" in

start)

#

# Start TlStat Data Serivce

#

$DAEMON_HOME/jsvc -user $MYJSVC_USER -home $JAVA_HOME -Djava.io.tmpdir=$TMP_DIR -wait 10 -pidfile $PID_FILE #控制台的输出会写到tlstat.out文件里

-outfile $MYJSVC_HOME/log/myjsvc.out -errfile '1' -cp $CLASSPATH #服务启动类

com.sohu.jsvc.test.TestJsvc

#

# To get a verbose JVM

#-verbose # To get a debug of jsvc.

#-debug exit $?

;;

stop)

#

# Stop TlStat Data Serivce

#

$DAEMON_HOME/jsvc -stop -pidfile $PID_FILE com.sohu.jsvc.test.TestJsvc

exit $?

;;

*)

echo "Usage myjsvc start/stop"

exit 1;;

esac

5. 把myjsvc文件拷贝到/etc/init.d/目录下

6. #chmod -c 777 /etc/init.d/myjsvc

7. 添加服务

#chkconfig --add myjsvc

#chkconfig --level 345 myjsvc on

8. 完成,启动服务

#service myjsvc start

你可以从/test/log/myjsvc.out文件里看到如下信息:

execute init(args) method

execute start method

#service myjsvc stop

你会发现/test/log/myjsvc.out文件里会增加如下信息

execute stop method

execute destroy method

并且在系统重启时会自动启动myjsvc服务

JAVA 怎么判断SFTP上某个文本文件是否存在?

File f = new File("文件全路径");

if(!f.exists()){

// 不存在

}else{

// 存在

}

jsp怎么连接数据库oracle

JSP连接Oracle10g数据库的方法:

%@ page contentType="text/html;charset=gb2312"%

%@ page import="java.sql.*" %

%@ page import="java.io.*" %

%@ page import="java.util.*" %

html

head

titleOracle数据库连接测试/title

/head

body

%

java.sql.Connection lConn = null;

java.sql.Statement lStat = null;

java.sql.ResultSet lRs = null;

try

{

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

String lUrl = "java:oracle:thin:@localhost:1521:orcl";

//java:oracle:thin: 表示使用的是thin驱动

//@srv:1521: 表示使用的服务器的名字和端口号

//dbname: 表示数据库的SID

lConn = DriverManager.getConnection(lUrl,"system","rg");

lStat = lConn.createStatement();

//创建表

String createTableCoffees = "CREATE TABLE COFFEES " +

"(COF_NAME VARCHAR(32), SUP_ID INTEGER, PRICE FLOAT, " +

"SALES INTEGER, TOTAL INTEGER)";

lStat.executeUpdate(createTableCoffees);

//插入数据

lStat.executeUpdate("INSERT INTO COFFEES VALUES ('Colombian', 101, 7.99, 0, 0)");

lStat.executeUpdate("INSERT INTO COFFEES VALUES ('Espresso', 150, 9.99, 0, 0)");

lStat.executeUpdate("INSERT INTO COFFEES VALUES ('Colombian_Decaf', 101, 8.99, 0, 0)");

lStat.executeUpdate("INSERT INTO COFFEES VALUES ('French_Roast_Decaf', 49, 9.99, 0, 0)");

//查询结果

lRs = lStat.executeQuery("select * from COFFEES");

//显示结果

out.println("table");

while (lRs.next()) {

out.print("trtd" + lRs.getString(1));

//COF_NAME

out.print( "td" + lRs.getInt(2));

//SUP_ID

out.print( "td" + lRs.getFloat(3));

//PRICE

out.print( "td" + lRs.getInt(4));

//SALES

out.println( "td" + lRs.getInt(5));

//TOTAL

}

out.println("/table");

lRs.close();

lStat.close();

} catch (SQLException e) {

throw new ServletException(e);

} finally {

try {

if (lConn != null)

lConn.close();

} catch (SQLException e) {

}

}

%

/body

/html

continue跳出本次循环的时候,本次循环当中的局部变量是否释放?具体代码如下

在c里面只要申明过一次,就会在内存里自动开辟出一块区域,直到程序结束,或者你手动释放才会释放出去,而且你第一次申明过了以后,以后所有的在此申明都不会替换这个区域,所以你第一次内存的数据会一直存在,除非你重新定义申明一个变量,或者你对这个区域内的内容作操作

javalstat的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、javalstat的信息别忘了在本站进行查找喔。