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.

The port should be 315, for example, 30015, if the instance is 00.<br />

You can specify one or more failover servers by adding additional hosts, as in the following example:<br />

jdbc:sap://myServer:30015,failover1:30015,failover2:30015/?<br />

autocommit=false<br />

Related Links<br />

The following is an example of connecting to an <strong>SAP</strong> <strong>HANA</strong> server called myhdb, which was installed as<br />

instance 07, with user name myname and password mysecret. Make sure to change these for your<br />

system, and add the JDBC driver (ngdbc.jar) to your classpath.<br />

import java.sql.*;<br />

public class jdemo {<br />

public static void main(String[] argv) {<br />

Connection connection = null;<br />

try {<br />

connection = DriverManager.getConnection(<br />

"jdbc:sap://myhdb:30715/?<br />

autocommit=false",myname,mysecret);<br />

} catch (SQLException e) {<br />

System.err.println("Connection Failed. User/Passwd Error?");<br />

return;<br />

}<br />

if (connection != null) {<br />

try {<br />

System.out.println("Connection to <strong>HANA</strong> successful!");<br />

Statement stmt = connection.createStatement();<br />

ResultSet resultSet = stmt.executeQuery("Select 'hello<br />

world' from dummy");<br />

resultSet.next();<br />

String hello = resultSet.getString(1);<br />

System.out.println(hello);<br />

} catch (SQLException e) {<br />

System.err.println("Query failed!");<br />

}<br />

}<br />

}<br />

}<br />

<strong>SAP</strong> <strong>HANA</strong> Database - Client Installation <strong>Guide</strong><br />

14.2.1 Tracing JDBC Connections<br />

You can activate the JDBC trace to find errors while your application is connected to a database via JDBC.<br />

You must be logged on as the operating system user who started (or will start) the JDBC application.<br />

Note:<br />

● You always activate the JDBC trace for all JDBC applications that the current operating system user<br />

has started.<br />

● Configuration changes have an effect on all JDBC applications that the current operating system user<br />

has started.<br />

When the JDBC trace is activated, the JDBC driver logs on the client the following information:<br />

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

Using Database Client Interfaces<br />

P U B L I C<br />

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

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

Saved successfully!

Ooh no, something went wrong!