From 6225fffd2e26756c4b0099bbb6d5f2b7843df925 Mon Sep 17 00:00:00 2001 From: mmcentre Date: Sun, 20 Jan 2019 18:12:03 -0500 Subject: [PATCH] MAB Create a sample POM file and IntelliJ IDEA Project --- Samples-java-helloworld.ipr | 23 ++++++++++ .../com/intersystems/samples/HelloWorld.java | 43 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/main/java/com/intersystems/samples/HelloWorld.java diff --git a/Samples-java-helloworld.ipr b/Samples-java-helloworld.ipr index 3e55a2f..ce542df 100644 --- a/Samples-java-helloworld.ipr +++ b/Samples-java-helloworld.ipr @@ -21,6 +21,14 @@ + + + true + true + com.intersystems.jdbc.IRISDriver + jdbc:IRIS://localhost:51773/SAMPLES + + @@ -321,12 +329,27 @@ + + + + + + + % + " + + + master_key + SuperUser + : + + diff --git a/src/main/java/com/intersystems/samples/HelloWorld.java b/src/main/java/com/intersystems/samples/HelloWorld.java new file mode 100644 index 0000000..725b6e7 --- /dev/null +++ b/src/main/java/com/intersystems/samples/HelloWorld.java @@ -0,0 +1,43 @@ +/* +* PURPOSE: Makes a connection to an instance of InterSystems IRIS Data Platform. +*/ +package com.intersystems.samples; + +import com.intersystems.jdbc.IRISDataSource; + +import java.sql.Connection; +import java.sql.SQLException; + +public class HelloWorld { + + public static void main(String[] args) { + String ip = "localhost"; + int port = 51773; + String namespace = "USER"; + String username = "SuperUser"; + String password = "SYS"; + try { + // Using IRISDataSource to connect + IRISDataSource ds = new IRISDataSource(); + + // Create connection string + String dbUrl = "jdbc:IRIS://" + ip + ":" + port + "/" + namespace; + ds.setURL(dbUrl); + ds.setUser(username); + ds.setPassword(password); + + // Making connection + Connection dbconnection = ds.getConnection(); + System.out.println("Hello World! You have successfully connected to InterSystems IRIS via JDBC."); + dbconnection.close(); + + } + catch ( SQLException e) + { + System.out.println(e.getMessage()); + } + } + +} + +