Hi John,
Good to hear that you are using Maven. This makes life simpler.

On a project which is Maven-based you do as follows:

In the Projects window in the IDE locate your project and specifically
the tree node named "Dependencies". Now right-click that node and
select "Download sources". This will make the IDE ask Maven to
download sources in addition to the actual jar. You can see on each
dependency in the tree if it has sources attached to it or not. (put
your mouse over the dependency). Unfortunately not all open source
projects remember to publish sources along with their JARs but the
vast majority does. In this regard Microsoft plays nicely as they
actually publish sources into Maven Central along with their jars [1].
The IDE download task takes place in the background so you get no
feedback other than the icons on each dependency in the "Dependencies"
node. Icons will change as the background download task progresses
through your project's dependencies.

>From now on the IDE knows about these attached sources and there's
nothing further you need to do. You never had to use the "Add local
sources" feature in the first place. Since you've done so already I
would - just to be sure - wipe out the relevant part of your local
Maven repo (using a File Explorer of your choice) and then rebuild
your project and then re-do the "Download sources" action from the
right-click menu.

Now you have your ducks lined up. You are now ready to debug Microsoft's code.

/Lars


[1]:  
https://repo1.maven.org/maven2/com/microsoft/sqlserver/mssql-jdbc/10.2.0.jre17/

On Fri, Feb 4, 2022 at 6:37 PM John <jbarrow...@gmail.com> wrote:
>
> Hi Lars,
>
>
>
> I use Maven and, while not an expert, use it to (for example) to check for 
> latest versions – e.g. mvn versions:use-latest-releases and so have automated 
> the tasks that I find useful. This only takes me a few seconds to do and, as 
> I am only developing locally as a hobby, I do this regularly so always 
> working on the latest version.
>
>
>
> My issue is focused on how NetBeans integrates those sources as the 
> information available on the web seems a bit thin and as I asked in my second 
> point, I can’t locate where in NetBeans to see the configuration settings I 
> have already made.
>
>
>
> Are you saying that I need to reference the source files inside my pom.xml 
> (I.e. a Maven solution) and that NetBeans will auto-reference that 
> information? I have checked the pom.xml file, and it only references the 
> dependency – I.e.
>
>
>
>         <dependency>
>
>             <groupId>com.microsoft.sqlserver</groupId>
>
>             <artifactId>mssql-jdbc</artifactId>
>
>             <version>10.2.0.jre17</version>
>
>             <type>jar</type>
>
>         </dependency>
>
>
>
> Since sending the email, I have explored the Maven repository (.m2) and 
> looking in
>
>
>
> C:\Users\John\.m2\repository\com\microsoft\sqlserver\mssql-jdbc\10.2.0.jre17
>
>
>
> I find that I have all the jar files for the sources and Javadoc.
>
>
>
> mssql-jdbc-10.2.0.jre17-javadoc.jar
>
> mssql-jdbc-10.2.0.jre17-javadoc.jar.sha1
>
> mssql-jdbc-10.2.0.jre17-sources.jar
>
> mssql-jdbc-10.2.0.jre17.jar
>
> mssql-jdbc-10.2.0.jre17.jar.sha1
>
> mssql-jdbc-10.2.0.jre17.pom
>
> mssql-jdbc-10.2.0.jre17.pom.sha1
>
>
>
> and used jar -tf mssql-jdbc-10.2.0.jre17-sources.jar to see that they have 
> the .java files I was expecting.
>
>
>
> So now I think that I have made a mistake when selecting the file in ‘Add 
> Local Sources’ to be the zip that I downloaded from GitHub which actually 
> contains the project if I wanted to build it locally!
>
>
>
> So, if that analysis is correct, then I am initially looking for help with 
> the following question of the three I initially posed so I can try linking up 
> with the mssql-jdbc-10.2.0.jre17-sources.jar in the Maven repository.
>
>
>
> > Out of curiosity, if I made a mistake and picked the wrong .zip file, how 
> > would I go about amending that setting to use a different .zip file.
>
>
>
> John
>
>
>
> From: Lars Bruun-Hansen
> Sent: 04 February 2022 16:42
> To: John
> Subject: Re: Integrate MS-SQL JDBC Sources into NetBeans to enable drilldown 
> of methods
>
>
>
> Hi John
>
> It seems to me that you are dealing with a lot of time consuming
>
> issues (downloading dependencies from odd places, attaching sources
>
> and what not) which most Java developers don't have to deal with. In
>
> short: I think you should invest time in learning Maven or Gradle. It
>
> will truly boost your productivity.
>
>
>
> Having said that, for your particular use-case, it is not obvious,
>
> even in the situation where Maven/Gradle had seamlessly done all the
>
> setup for your (this setup is a prerequisite). Even with all your
>
> ducks lined up (sources downloaded and attached) you still face the
>
> minor problem that all the JDBC objects are really interfaces. So when
>
> you Ctrl-click on a method you will be taken to the interface class,
>
> not its particular implementation (in your case Microsoft's JDBC
>
> driver). The trick for that would be to use the debugger. This will
>
> lead you into the source code for the actual implementation, not
>
> merely the JDBC interface class. Then you can learn from Microsoft's
>
> code if that is what you want.
>
>
>
> /Lars
>
>
>
> On Fri, Feb 4, 2022 at 5:08 PM John <jbarrow...@gmail.com> wrote:
>
> >
>
> > Good afternoon,
>
> >
>
> >
>
> >
>
> > I am running the latest versions of NetBeans (12.6), JDK 17 and MS-SQL JDBC 
> > driver 10.2 on Windows 10.
>
> >
>
> >
>
> >
>
> > I want to integrate the JDBC sources into NetBeans so that, if I 
> > <Ctrl-Click> on a method (e.g. setAutoCommit of 
> > java.sql.Connection.setAutoCommit(boolean), NetBeans will take me to the 
> > source file and then allow me to drill-down further within the source of 
> > that method, just as I can do for my own methods.
>
> >
>
> >
>
> >
>
> > I can do it for all of the JDK – (e.g. String class or String.length()) and 
> > this is excellent.
>
> >
>
> >
>
> >
>
> > Firstly, I went to the ‘Projects’ tab, located the ‘Dependencies’ folder 
> > for my project and opened the folder to locate the jar file for the MS-SQL 
> > JDBC support.
>
> >
>
> > I discovered that if you <right-click> on the mssql-jdbc-10.2.0.jre17.jar, 
> > you get an option to ‘Download the JavaDoc’ and ‘Add local sources’. I had 
> > previously downloaded the latest sources as a .zip file from 
> > https://github.com/microsoft/mssql-jdbc/releases into a folder on my local 
> > disk.
>
> >
>
> >
>
> >
>
> > So, I selected both of those.
>
> >
>
> > I Downloaded the JavaDoc as I didn’t know where the SQL JavaDoc was on the 
> > web.
>
> >
>
> > For the Local Sources, I pointed at the zip file that I had previously 
> > downloaded.
>
> >
>
> >
>
> >
>
> > Neither gave any confirmation of completion but when I <right-click> again, 
> > the options have disappeared and so I am assuming that NetBeans now knows 
> > about them.
>
> >
>
> >
>
> >
>
> > Anyway, the JavaDoc download appears to have worked as get the relevant 
> > popup when hover over the method but when I <Ctrl-Click> the method it 
> > takes me into a generated interface with the message at the top of the tab 
> > saying “Showing generated source file. No sources are attached to class jar 
> > file”.
>
> >
>
> >
>
> >
>
> > I googled that message and was pointed to the Tools > Java Platforms and 
> > while it looks to be just for the JDK, there was a Sources tab and an 
> > option to add in a zip to the long list that was already there. I therefore 
> > added the “mssql-jdbc-10.2.0.zip” file, containing the sources into the 
> > list and re-loaded NetBeans, but that didn’t appear to make any difference.
>
> >
>
> >
>
> >
>
> > So, I must be missing a key link here. Can someone give me some advice as 
> > to what I am doing wrong
>
> >
>
> >
>
> >
>
> > How do I integrate the MS-SQL sources zip file into NetBeans
>
> > Given that I have <right-click> on the mssql-jdbc-10.2.0.jre17.jar to ‘Add 
> > local sources’, how can I locate the environment setting that I gave 
> > NetBeans detailing the file location. <right-click> then Properties on the 
> > mssql-jdbc-10.2.0.jre17.jar file, tells me that ‘Sources locally’ is ticked 
> > and greyed out, but nothing more
>
> > Out of curiosity, if I made a mistake and picked the wrong .zip file, how 
> > would I go about amending that setting to use a different .zip file.
>
> >
>
> >
>
> >
>
> > If I unzip the sources that are within the .zip, then I can locate the full 
> > source of the method using an external editor, but I would obviously far 
> > rather use the power of NetBeans to create a fully integrated solution.
>
> >
>
> >
>
> >
>
> > I love the fact that I can drilldown into the JDK, it gives me a valuable 
> > insight into how each of the methods is coded and a view of how others 
> > write their Java.
>
> >
>
> >
>
> >
>
> > Thanks in advance
>
> >
>
> >
>
> >
>
> > John
>
> >
>
> >
>
> >
>
> > --------------------------------------------------------------------- To 
> > unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org For additional 
> > commands, e-mail: users-h...@netbeans.apache.org For further information 
> > about the NetBeans mailing lists, visit: 
> > https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to