0

I apologise if the title is vague or confusing, English is not my mother tongue and I am really giving my best to keep the grammar and spelling correct.

I was checking out how DriverManager and JDBC in Java works so I tried setting up a connection to my database. I use Netbeans for my Java coding. I tried using the getConnection method but I was confused by the order of the parameters the function takes. I got it all to work eventually but one thing I noticed was that for me the parameter names are displayed basically like this: "String string, String string1, String string2" in the "tooltip" for all the different overloads.

While I see that for certain people and in the Oracle docs website for DriverManager, the parameters are displayed as: "String url, String user, String password". I realise I can read the order in the javadoc, but I think it would really be helpful if the parameter names were for me like that too.

So instead of having "String string, String string1, String string2" I want to have have "String url, String user, String password".

Incase you are not sure of what I am talking about, Here is a screenshot:

Parameters tooltip

Does anyone have an idea on how to enable this? How to change it ? Tried googling but to no success. That might be because of my bad english and due to the terminology being quite off.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • @DiabolicWords Re "This is the method-signature thought up and programmed by the developers of this DriverManager", that is not correct. **DriverManager** is a JDK class, and by viewing the source code you can see that the parameters for getConnection() were given meaningful names. – skomisa Mar 18 '18 at 20:00

1 Answers1

1

I can't reproduce your problem. This is what I see in NetBeans 8.2:

prompting

Have you set Sources and JavaDoc for the JDK you are using? To check, go to Tools > Java Platforms and select the platform you are using, then look at the Sources and Javadoc tabs. This is what I have:

prompting2

If they are not set then try setting them to see if that fixes the problem. If they are set can you update the OP with a screen shot of what you have?

skomisa
  • 16,436
  • 7
  • 61
  • 102
  • Okay so I checked my source and javadoc and compared them with yours. They are not the same. Mine look like this : https://imgur.com/a/BMjFD – Benjamin Bajic Mar 18 '18 at 20:04
  • I believe the auto-complete only relies on presence of the sources, not on the javadoc links. – Mark Rotteveel Mar 18 '18 at 20:20
  • OK. Your **Javadoc** tab looks good, but you need to add **src.zip** to your **Sources** tab. If you have a zip file named **C:\Program Files\Java\jdk1.8.0_151\src.zip** then click the **Add JAR/Folder** button to add it. Then try **DriverManager.get** again to see if the parameters have better names. – skomisa Mar 18 '18 at 20:23
  • @MarkRotteveel I do as well. I just figured that it was worth checking both tabs to avoid a follow up question on Javadoc problems. – skomisa Mar 18 '18 at 20:25
  • I checked my jdk1.8.0_151 folder and it has only javafx-src.zip. – Benjamin Bajic Mar 18 '18 at 20:28
  • @BenjaminBajic Then you should reinstall the JDK and make sure to install the sources – Mark Rotteveel Mar 18 '18 at 20:38
  • @BenjaminBajic As Mark suggests, it looks like you may have chosen not to install the source during the installation of 151. See https://stackoverflow.com/questions/29258944/where-is-the-src-zip-for-jdk8u40 where someone had a similar problem with 8u40. – skomisa Mar 18 '18 at 20:40
  • @BenjaminBajic Unfortunately I don't see an easy way to add **src.zip** without reinstalling, unless you happen to have another copy of **src.zip** lying around from some earlier release of Java 8; that should work fine. But if you are going to reinstall JDK I suggest going with the latest version rather than 151. – skomisa Mar 18 '18 at 20:52
  • @BenjaminBajic It looks like there may be an easy way to get **src.zip** after all! Pretend to reinstall 151 but do not go past the first screen, then follow the instructions here: https://bgasparotto.com/extract-src-zip-jdk-installer – skomisa Mar 18 '18 at 21:04
  • @skomisa thank you so much! It worked perfectly. Now my parameters actually have names and its soo much easier. It worked perfectly. Thank you once more. – Benjamin Bajic Mar 18 '18 at 21:49
  • I am now getting the same issue, just with other methods. The fix above did not work for this case. – Benjamin Bajic Aug 17 '18 at 21:40
  • @BenjaminBajic OK. Has anything significant been modified since it worked? For example, have you possibly upgraded NetBeans and/or the JDK, or are they unchanged? If you provide the name of a class/method that does not work now, I will check it in my environment. – skomisa Aug 17 '18 at 23:02
  • @skomisa no, nothing. My DriverManager class still works fine, but example extending DefaultHandler class when using SAX, methods such as startElement, endElement etc all have very different names. I am attaching a link to a picture here : https://imgur.com/a/JFc1kRz. The bottom one is how it should look like, while the top one is how it looks for me. – Benjamin Bajic Aug 18 '18 at 13:08
  • @BenjaminBajic Strange - autocomplete with **DefaultHandler** is working for me. To be clear, in your class that extends **DefaultHandler**, if you place the cursor over the literal value _"startElement"_ in your override of the **startElement()** method, and then right-click and select _"Go to Super Implementation"_ from the context menu, what do you see in the file named **DefaultHandler.java** that opens? Do the parameter names for **DefaultHandler.startElement()** look correct, as in the bottom half of your screen shot, or wrong as in the top half of your screen shot? – skomisa Aug 26 '18 at 02:59