The following example shows the source code of the HelloMaxDB Java class.
The individual steps are listed in the comments in the example.
Syntax
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 */ 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 (); } }