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()); + } + } + +} + +