Add helloworld sample

This commit is contained in:
semanej 2019-01-16 16:30:35 -05:00
parent a006ecda9d
commit 1bf84c4bc1
5 changed files with 78 additions and 0 deletions

7
.classpath Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/intersystems-jdbc-3.0.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>samples-java-helloworld</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

Binary file not shown.

43
src/demo/HelloWorld.java Normal file
View File

@ -0,0 +1,43 @@
/*
* PURPOSE: Makes a connection to an instance of InterSystems IRIS Data Platform.
*/
package demo;
import java.sql.Connection;
import java.sql.SQLException;
import com.intersystems.jdbc.IRISDataSource;
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());
}
}
}