Javamelody and Oracle without datasource but using driver directly

530 views
Skip to first unread message

Vincenzo Lizio

unread,
Jul 8, 2016, 4:21:45 AM7/8/16
to javamelody
Hi,
I use Javamelody for monitoring my app.
I have Oracle db and using driver directly (no datasource, no jndi).
I haven't sql statistics.

[web.xml]
...
    <property name="hibernate.connection.driver_class">net.bull.javamelody.JdbcDriver</property>
    <property name="hibernate.connection.driver">oracle.jdbc.OracleDriver</property>
    <property name="hibernate.connection.url">jdbc:oracle:thin:@myserver:1521:mysid</property>
    <property name="hibernate.connection.username">myuser</property>
    <property name="hibernate.connection.password">mypassword</property>      

    <filter>
        <filter-name>monitoring</filter-name>
        <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
        <init-param>
            <!-- restrict access using HTTP basic authentication -->
            <param-name>authorized-users</param-name>
            <param-value>myuser:mypassword</param-value>
        </init-param>
        <init-param>
            <!-- enable/disable JavaMelody -->
            <param-name>disabled</param-name>
            <param-value>false</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>monitoring</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <listener>
        <listener-class>net.bull.javamelody.SessionListener</listener-class>
    </listener>
...

java class using oracle db example:
...
        try {
            String url = "jdbc:oracle:thin:@" + hst + ":" + prt + ":" + sid;
            OracleDataSource ods = new OracleDataSource();
            ods.setUser(uid);
            ods.setPassword(pwd);
            ods.setURL(url);
            dbConn = ods.getConnection();
            dbConn.setAutoCommit(false);
...
        try {
            sqlStmt = connection.createStatement();
            resultSet = sqlStmt.executeQuery(query);
...

Oracle user have grant to access to v$session

Many thank's
Vincenzo

Vernat Emeric

unread,
Jul 9, 2016, 7:53:48 AM7/9/16
to javam...@googlegroups.com
Hi Vincenzo,

If you have:
            dbConn = ods.getConnection();
then you can monitor sql requests and jdbc connections with:
            dbConn = net.bull.javamelody.JdbcWrapper.SINGLETON.createConnectionProxy(dbConn);

bye,
Emeric
--

---
You received this message because you are subscribed to the Google Groups "javamelody" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javamelody+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Reply all
Reply to author
Forward
0 new messages