#!/bin/sh
# You might want to change these values to run the example.
JDBC_JAR="$1"
DRIVER="$2"
URL="$3"
USER="$4"
PASSWORD="$5"

# Example settings for MaxDB:
# JDBC_JAR=../jdbc/sapdbc.jar
# DRIVER=com.sap.dbtech.jdbc.DriverSapDB
# URL=jdbc:sapdb://localhost/<SID>
# USER=SAP<SID>DB

if [ "x$JDBC_JAR" = "x" ]; then
  echo "ERROR: Missing JDBC driver jar file for the database connection."
  exit 1
fi
if [ "x$DRIVER" = "x" ]; then
  echo "ERROR: Missing JDBC driver class name for the database connection."
  goto :errorend
fi
if [ "x$URL" = "x" ]; then
  echo "ERROR: Missing URL for the database connection."
  goto :errorend
fi
if [ "x$USER" = "x" ]; then
  echo "ERROR: Missing USER for the database connection."
  goto :errorend
fi
if [ "x$PASSWORD" = "x" ]; then
  echo "ERROR: Missing PASSWORD for the database connection."
  goto :errorend
fi

if [ "x$JAVA_HOME" = "x" ]; then
  # use java executable from PATH, if JAVA_HOME is not set.
  JAVA_CMD=java
else
  # use java executable from JAVA_HOME, if JAVA_HOME is set.
  JAVA_CMD="$JAVA_HOME/bin/java"
fi

LIBS=lib/persistence-api-1.0.jar:lib/orpersistence.jar:lib/jaxrpc-api.jar:lib/jaxm.jar:lib/sap.com~tc~antlr~runtime.jar

$JAVA_CMD -classpath orpersistence_example.jar:"$LIBS":"$JDBC_JAR" com.sap.test.orpersistence.ExampleWithMap "$DRIVER" "$URL" "$USER" "$PASSWORD"