Content Type
Video
Duration
4m
Level
Introductory
Learn how to use JDBC to connect your Java applications to InterSystems IRIS® data platform.
Mark me "complete" for this video.
Content Type
Video
Duration
4m
Level
Introductory
Learn how to use JDBC to connect your Java applications to InterSystems IRIS® data platform.
Mark me "complete" for this video.
| Reference | Timestamp | Code |
|---|---|---|
| Location of the JDBC Driver | 0:45 | or
|
| URL (connection string) | 0:53 | jdbc:IRIS://host_IP:SuperServerPort/namespace |
| Java class that connects to InterSystems IRIS using the JDBC driver, then creates a statement object and executes a SQL query | n/a | Begin code:import com.intersystems.jdbc.*;
public class JDBCLearnTaxi {
public static void main (String[] args) {
String dbUrl = “jdbc:IRIS://127.0.0.1:1972/User”; //replace
String user = “superuser”;
String pass = “SYS”;
try {
IRISDataSource ds = new IRISDataSource();
ds.setURL(dbUrl);
ds.setUser(user);
ds.setPassword(pass);
Connection dbconnection = ds.getConnection();
System.out.println(“Connected to InterSystems IRIS via JDBC.”);
Statement myStatement = dbconnection.createStatement();
ResultSet myRS = myStatement.executeQuery(“select * from zeppelin.GreenTrip”);
//READ
while (myRS.next()) {
String venderID = myRS.getString(“vendorID”);
String tripType = myRS.getString(“Trip_type”);
String passCount = myRS.getString(“passenger_count”);
Date tipAmount = myRS.getDate(“Tip_amount”);
System.out.println(venderID + “\t”+tripType + “\t” + passCount + “\t” + tipAmount);
}
}
catch (SQLException e)
{
System.out.println(e.getMessage());
}
}
}End code |
以下でも利用可能です
![]()
Having an issue with the learning site? Want to provide feedback on a course? Contact us by emailing online.training@intersystems.com.
Please include all relevant information, including the page or course you are having trouble with, and any necessary screenshots.