28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

If the driver is installed properly, you should get the ODBC login screen.<br />

Note: You can also run the command odbcreg -g or odbcreg32 -g to get a list of installed<br />

drivers. The <strong>SAP</strong> <strong>HANA</strong> driver is called HDBODBC.<br />

3. Test your ability to connect by entering connection information (system, port, user name and password) and<br />

select OK. The tool closes and the results of the test are printed in the command window.<br />

You can also run odbcreg -g to get a list of installed ODBC drivers, and check to make sure that the <strong>SAP</strong> <strong>HANA</strong><br />

driver (either HDBODBC or HDBODBC32) is installed.<br />

14.2 Connecting via JDBC<br />

<strong>SAP</strong> <strong>HANA</strong> provides a JDBC driver for connecting Java applications to the database.<br />

1. Install the JDBC driver.<br />

The driver (ngdbc.jar) is installed as part of the <strong>SAP</strong> <strong>HANA</strong> client installation and is located at:<br />

○ C:\Program Files\sap\hdbclient\ on Microsoft Windows platforms<br />

○ /usr/sap/hdbclient/ on Linux and UNIX platforms<br />

2. Add ngdbc.jar to your classpath.<br />

3. If you are on a version of Java earlier than Java 6, load the JDBC driver class, which is called<br />

com.sap.db.jdbc.Driver.<br />

4. Write Java code to create a connection to the database and execute SQL commands. Use a connection string<br />

in the form of jdbc:sap://:[/?]. For example:<br />

358<br />

jdbc:sap://myServer:30015/?autocommit=false<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Using Database Client Interfaces

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!