@@ -103,13 +103,33 @@ JDBC Driver supports the same data formats as the underlying [client](/docs/en/i
103
103
## Creating Connection
104
104
105
105
``` java
106
- String url = " jdbc:ch://my-server:8123/system" ; // use http protocol
106
+ String url = " jdbc:ch://my-server:8123/system" ;
107
107
108
108
Properties properties = new Properties ();
109
+ DataSource dataSource = new DataSource (url, properties);// DataSource or DriverManager are the main entry points
110
+ try (Connection conn = dataSource. getConnection()) {
111
+ ... // do something with the connection
112
+ ```
109
113
110
- DataSource dataSource = new DataSource (url, properties);
111
- try (Connection conn = dataSource. getConnection(" default" , " password" );
112
- Statement stmt = conn. createStatement()) {
114
+ ## Supplying Credentials and Settings
115
+
116
+ ```java showLineNumbers
117
+ String url = " jdbc:ch://localhost:8123?jdbc_ignore_unsupported_values=true&socket_timeout=10" ;
118
+
119
+ Properties info = new Properties ();
120
+ info. put(" user" , " default" );
121
+ info. put(" password" , " password" );
122
+ info. put(" database" , " some_db" );
123
+
124
+ // Creating a connection with DataSource
125
+ DataSource dataSource = new DataSource (url, info);
126
+ try (Connection conn = dataSource. getConnection()) {
127
+ ... // do something with the connection
128
+ }
129
+
130
+ // Alternate approach using the DriverManager
131
+ try (Connection conn = DriverManager . getConnection(url, info)) {
132
+ ... // do something with the connection
113
133
}
114
134
```
115
135
0 commit comments