me0wster / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

Add possibility to pass Driver through JDBC-URL #247

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using javamelody to monitor a Coldfusion 10 installation running on Tomcat, 
but it could be any application on any j2ee-Server where you dont have the code 
yourself. The monitoring works fine except for the SQL-Monitoring. The problem 
I am facing is that in this software I configure the SQL-datasources through a 
GUI and there is no way I can add a custom Property (Driver). However what I 
can is define the JDBC-Url to connect to (and this seems to me a situation, you 
may have in many cases).
It would be nice if you could specify the real driver by a parameter in the 
JDBC-Url, i.e. 

jdbc:mysql://localhost:3306/prod?characterEncoding=latin1&Driver=com.mysql.jdbc.
Driver

Now I'm not a java developper, but from what I've seen, it should be possible 
by changing the funciton connect in JdbcDriver.java to something like

        @Override
        public Connection connect(String url, Properties info) throws SQLException {
                String proxiedDriver = info.getProperty("driver");
                if (proxiedDriver == null) {
                        List<NameValuePair> params = URLEncodedUtils.parse(new URI(url), "UTF-8");
                        for (NameValuePair param : params) if(param.getName().equals("Driver")) proxiedDriver=param.getValue();
                }
                if (proxiedDriver == null) {
                        // si pas de proprié driver alors ce n'est pas pour nous
                        // (on passe ici lors du DriverManager.getConnection ci-dessous)
                        return null;
                }
                try {
                        Class.forName(proxiedDriver);
...

(again: I'm not a java programmer.... maybe I've done this completly the wrong 
way round)

Does this sound like a possible enhancement ?

Thank you
Frank

Original issue reported on code.google.com by f...@neteducation.com on 22 Aug 2012 at 1:06

GoogleCodeExporter commented 9 years ago
hmm,... didnt mean to open this as a defect... how can i change it to feature 
request?

Original comment by f...@neteducation.com on 22 Aug 2012 at 1:22

GoogleCodeExporter commented 9 years ago

Original comment by evernat@free.fr on 22 Aug 2012 at 1:27

GoogleCodeExporter commented 9 years ago
Hello guys, Im facing the same problem, i set the connection through JDBC URL 
which looks like this 
jdbc:mondrian:Jdbc=jdbc:postgresql://host:5432/MyDB;Catalog=res:catalog.xml;Jdbc
Drivers=org.postgresql.Driver;
This URL is passed to java.sql.DriverManager.getConnection(url, 
username,password);

Is there a way i do the right configuration of the JDBC monitoring?
Thank you,
Pavel

Original comment by p.bob...@gmail.com on 3 Jan 2014 at 9:54