viernes, 27 de marzo de 2015

Creating a database connection to SAP ASE 16 from NetBeans

I would like to start saying this was a pain in the neck for sure, if I think this, the hardest part was the lack support from the SAP guys, specifically the official docs, independent blogs or user's list. So one client has a deployment  using SAP ASE, formerly called Sybase, it's a must to keep that DBMS -first weird decision- That's why I have to download latest ASE available to try connect it from NetBeans because the new project will use JSF -cool, but over ASE? even weird decision. So after many failed test here are the steps to connect to over Linux:

1. download ASE from SAP's website, the installation process is windows style: graphical, lack of details, slow, heavier, etc. Just try to take notes about the port connections. The server is started using a weird script, anyway, I installed it on /opt.

2. after start from command line, start glassfish and load Netbeans

3. from your project go to the services tab and create a new driver, then look for the jconn4.jar file, this is supplied from the ASE installation, you may download it from the official site as well.

4. find the main class using the button FIND, the class is the jdbc4 one.

5. then go to Database Option and choose "New Connection" option, load the driver you have created, click on next button.

6. in the next window type the USer Name and PAssword, you may use the 'sa' user in case you are not created another one, for this test is ok.

7. the most important part is this, the JBC Url, the sintaxis is this: jdbc:sybase:Tds::
now, from here I spend like 5 days figuring out why I could not connect to it, I was sure about the server's name and the port but I always got this error: UnknownHostException.  Here I discovered the lack of this DBMS, the official docs are usefulness, there is no end user support at blogs, social networks nor IRC, it was really cruel at this point.

8. so I decided to face this from another point of view, I used netstat to check if the port was available:
  netstat -atun

9. if you want to be more specific you may use:
 netstat -tulnp | grep 5000

So I found the port is listening but I figured out about the hostname (127.0.1.1) so I decided to include it in the JDBC url instead of server's name, so the url was: jdbc:sybase:Tds:127.0.1.1:5000

10. just press "Test Connection" button and... it works

and that's it, I can start to code my JSF CRUD's , in case you decide to work with ASE - for some weird decision- this will be really useful for you

Best!