## Example: HelloMaxDB

The following example shows the source text of the Java class HelloMaxDB.

The individual steps are listed in the comments in the example.

#### HelloMaxDB.java

import java.sql.*;

public class HelloMaxDB

{

public static void main(String[] args)

throws ClassNotFoundException, SQLException

{

String username = "MONA";

String password = "RED";

String host = "";

String dbname = "DEMODB";

/*

* Load JDBC Driver

*/

Class.forName ("com.sap.dbtech.jdbc.DriverSapDB");

/*

* Define Connection URL

*/

String url = "jdbc:sapdb://" + host + "/" + dbname;

/*

* Connect to the Database Instance

*/

Connection connection = DriverManager.getConnection (url, username, password);

/*

* Execute SQL Statements

*/

Statement stmt = connection.createStatement ();

ResultSet resultSet = stmt.executeQuery ("SELECT * FROM HOTEL.CUSTOMER");

resultSet.next ();

String hello = resultSet.getString (1);

System.out.println (hello);

/*

* close all objects

*/

resultSet.close ();

stmt.close();

connection.close ();

}

}