Rules for detecting open database resource(connection/stream/resultsetetc) - java

671 views
Skip to first unread message

somnat...@gmail.com

unread,
Dec 4, 2015, 2:42:55 PM12/4/15
to SonarQube
Hello Techies,

             I am trying to test the rule which checks for DB resource not being closed . However I don't see the rule getting triggered .  When I browse the rules, I see the below 2 rules deprecated. 


It says to use S2095. How to use this rule ? Wouldn't this rule be automatically invoked  when the database connection is not being closed in the java code ? 

I am using sonar way as quality profile. Sonarqube version 5.1.2 and java plugin version "sonar-java-plugin-3.0". Please let me know 

Regards
Somnath

G. Ann Campbell

unread,
Dec 4, 2015, 4:27:36 PM12/4/15
to SonarQube, somnat...@gmail.com
Both the Java Plugin version of the rule and the FindBugs version require bytecode to work properly, so make sure you're providing that to the analysis. If you're not getting issues when you should, that's likely the cause.

BTW, neither version of the rule will monitor your running code. Instead, they each examine the logic in the program to make sure that when they see a resource opened, they can also see (in the appropriate execution path) that resource get closed.


HTH,
Ann

somnat...@gmail.com

unread,
Dec 4, 2015, 5:39:11 PM12/4/15
to SonarQube, somnat...@gmail.com
Thanks a lot Ann  for your reply. .. it seems I didnot provide the .class file with the .java file. Do I need to provide the .class file along with the .java file as well ? should the .java and .class file be present in the same folder ? 

Regards
Somnath

G. Ann Campbell

unread,
Dec 7, 2015, 7:22:09 AM12/7/15
to somnat...@gmail.com, SonarQube



---
G. Ann CAMPBELL | SonarSource
Product Owner

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/n-rJfzKG_-A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/30d7b853-cac2-4282-b09b-c89614f0c92b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages