Products | Versions |
---|---|
TIBCO Streaming | 10.6 |
How can I connect to a Microsoft SQL Server database from my Streaming and/or LiveView applications?
jdbc:sqlserver://<dbhost>:<dbport>;databaseName=<dbname>.where:
docker pull mcr.microsoft.com/mssql/server:2017-latest docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=P@ssw0rd!' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latestThis will start a local SQL Server 2017 database with database name master. For this database, you would use the following connection URL:
jdbc:sqlserver://localhost:1433;databaseName=masterNext, install a compatible mssql-jdbc driver into your Maven repository. To determine the correct driver for your SQL Server version, refer to Microsoft's guidance here. Typically, it is best to download the latest driver that is compatible with both your SQL Server database version and the JDK version used to run your Streaming application. For example:
mvn install:install-file -Dfile=mssql-jdbc-9.2.1.jre8.jar -DgroupId=com.microsoft.sqlserver -DartifactId=mssql-jdbc -Dversion=9.2.1.jre8 -Dpackaging=jarThen add the driver as a dependency in your project's pom.xml:
<dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>9.2.1.jre8</version> </dependency>Finally, create a JDBC HOCON configuration:
configuration = { JDBCDataSourceGroup = { jdbcDataSources = { "mssql2017" = { driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver" serverURL = "jdbc:sqlserver://localhost:1433;databaseName=master" userName = "sa" password = "P@ssw0rd!" } } } }You are now configured to connect to your SQL Server data source.