@echo off
setlocal

rem You might want to change these values to run the example.
set JDBC_JAR="%1"
set DRIVER="%2"
set URL="%3"
set USER="%4"
set PASSWORD="%5"

rem Example settings for MaxDB:
rem set JDBC_JAR=..\jdbc\sapdbc.jar
rem set DRIVER=com.sap.dbtech.jdbc.DriverSapDB
rem set URL=jdbc:sapdb://localhost/<SID>
rem set USER=SAP<SID>DB

if "x%JDBC_JAR%" == "x""" (
  echo ERROR: Missing JDBC driver jar file for the database connection.
  goto :errorend
)
if "x%DRIVER%" == "x""" (
  echo ERROR: Missing JDBC driver class name for the database connection.
  goto :errorend
)
if "x%URL%" == "x""" (
  echo ERROR: Missing URL for the database connection.
  goto :errorend
)
if "x%USER%" == "x""" (
  echo ERROR: Missing USER for the database connection.
  goto :errorend
)
if "x%PASSWORD%" == "x""" (
  echo ERROR: Missing PASSWORD for the database connection.
  goto :errorend
)

if "x%JAVA_HOME%" == "x" (
  rem use java executable from PATH, if JAVA_HOME is not set.
  set JAVA_CMD=java
) else (
  rem use java executable from JAVA_HOME, if JAVA_HOME is set.
  set JAVA_CMD="%JAVA_HOME%\bin\java"
)

set 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%

endlocal

if "0" == "%ERRORLEVEL%" goto :end
echo Program terminated abnormally
:errorend
pause
:end
