Add retrieve simple data
This commit is contained in:
parent
9bd8cf757f
commit
4256dbc803
|
@ -1,11 +1,13 @@
|
|||
/*
|
||||
* PURPOSE: Makes a connection to an instance of InterSystems IRIS Data Platform.
|
||||
* PURPOSE: Makes a connection to an instance of InterSystems IRIS Data Platform. This example also retrieves petstore data that is available within a trial instance of InterSystems IRIS.
|
||||
*/
|
||||
|
||||
import com.intersystems.jdbc.IRISDataSource;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
public class HelloWorld {
|
||||
|
||||
|
@ -28,7 +30,18 @@ public class HelloWorld {
|
|||
// Making connection
|
||||
Connection dbconnection = ds.getConnection();
|
||||
System.out.println("Hello World! You have successfully connected to InterSystems IRIS via JDBC.");
|
||||
dbconnection.close();
|
||||
|
||||
// Retrieve first 5 yellow birds from InterSystems IRIS using JDBC
|
||||
String sql = "SELECT TOP(5) name from Demo.Pet where color='Yellow' and type='bird'";
|
||||
PreparedStatement myStatement = dbconnection.prepareStatement(sql);
|
||||
ResultSet myRS = myStatement.executeQuery();
|
||||
System.out.println("Name");
|
||||
while (myRS.next())
|
||||
{
|
||||
String name= myRS.getString("Name");
|
||||
System.out.println(name);
|
||||
}
|
||||
dbconnection.close();
|
||||
|
||||
}
|
||||
catch ( SQLException e)
|
||||
|
|
Loading…
Reference in New Issue