Skip to content

Commit 862b287

Browse files
committed
Normalize indentation, remove trailing spaces
1 parent 5b1326e commit 862b287

File tree

5 files changed

+159
-165
lines changed

5 files changed

+159
-165
lines changed

articles/postgresql/hyperscale/howto-app-stacks-csharp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: saimicrosoft
66
ms.service: postgresql
77
ms.subservice: hyperscale-citus
88
ms.topic: how-to
9-
ms.date: 06/20/2022
9+
ms.date: 07/26/2022
1010
---
1111

1212
# C# app to connect and query Hyperscale (Citus)

articles/postgresql/hyperscale/howto-app-stacks-java.md

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: saimicrosoft
66
ms.service: postgresql
77
ms.subservice: hyperscale-citus
88
ms.topic: how-to
9-
ms.date: 06/20/2022
9+
ms.date: 07/26/2022
1010
---
1111

1212
# Java app to connect and query Hyperscale (Citus)
@@ -173,37 +173,35 @@ import javax.sql.DataSource;
173173
import com.zaxxer.hikari.HikariDataSource;
174174

175175
public class DButil {
176-
private static final String DB_USERNAME = "db.username";
177-
private static final String DB_PASSWORD = "db.password";
178-
private static final String DB_URL = "db.url";
179-
private static final String DB_DRIVER_CLASS = "driver.class.name";
180-
private static Properties properties = null;
181-
private static HikariDataSource datasource;
182-
183-
static {
184-
try {
185-
properties = new Properties();
186-
properties .load(new FileInputStream("src/main/java/application.properties"));
187-
datasource = new HikariDataSource();
188-
datasource.setDriverClassName(properties.getProperty(DB_DRIVER_CLASS ));
189-
datasource.setJdbcUrl(properties.getProperty(DB_URL));
190-
datasource.setUsername(properties.getProperty(DB_USERNAME));
191-
datasource.setPassword(properties.getProperty(DB_PASSWORD));
192-
datasource.setMinimumIdle(100);
193-
datasource.setMaximumPoolSize(1000000000);
194-
datasource.setAutoCommit(false);
195-
datasource.setLoginTimeout(3);
196-
197-
198-
}catch (IOException | SQLException e) {
199-
e.printStackTrace();
176+
private static final String DB_USERNAME = "db.username";
177+
private static final String DB_PASSWORD = "db.password";
178+
private static final String DB_URL = "db.url";
179+
private static final String DB_DRIVER_CLASS = "driver.class.name";
180+
private static Properties properties = null;
181+
private static HikariDataSource datasource;
182+
183+
static {
184+
try {
185+
properties = new Properties();
186+
properties.load(new FileInputStream("src/main/java/application.properties"));
187+
188+
datasource = new HikariDataSource();
189+
datasource.setDriverClassName(properties.getProperty(DB_DRIVER_CLASS ));
190+
datasource.setJdbcUrl(properties.getProperty(DB_URL));
191+
datasource.setUsername(properties.getProperty(DB_USERNAME));
192+
datasource.setPassword(properties.getProperty(DB_PASSWORD));
193+
datasource.setMinimumIdle(100);
194+
datasource.setMaximumPoolSize(1000000000);
195+
datasource.setAutoCommit(false);
196+
datasource.setLoginTimeout(3);
197+
} catch (IOException | SQLException e) {
198+
e.printStackTrace();
199+
}
200200
}
201-
202-
}
203-
public static DataSource getDataSource() {
204-
return datasource;
205-
}
201+
public static DataSource getDataSource() {
202+
return datasource;
206203
}
204+
}
207205
```
208206

209207
Create a `src/main/java/DemoApplication.java` file that contains:
@@ -335,12 +333,12 @@ public class Pharmacy {
335333
@Override
336334
public String toString() {
337335
return "TPharmacy{" +
338-
"pharmacy_id=" + pharmacy_id +
339-
", pharmacy_name='" + pharmacy_name + '\'' +
340-
", city='" + city + '\'' +
341-
", state='" + state + '\'' +
342-
", zip_code='" + zip_code + '\'' +
343-
'}';
336+
"pharmacy_id=" + pharmacy_id +
337+
", pharmacy_name='" + pharmacy_name + '\'' +
338+
", city='" + city + '\'' +
339+
", state='" + state + '\'' +
340+
", zip_code='" + zip_code + '\'' +
341+
'}';
344342
}
345343
}
346344
```
@@ -534,15 +532,16 @@ The following code is an example for copying data from a CSV file to a database
534532
It requires the file [pharmacies.csv](https://download.microsoft.com/download/d/8/d/d8d5673e-7cbf-4e13-b3e9-047b05fc1d46/pharmacies.csv).
535533

536534
```java
537-
public static long copyFromFile(Connection connection, String filePath, String tableName)
538-
throws SQLException, IOException {
535+
public static long
536+
copyFromFile(Connection connection, String filePath, String tableName)
537+
throws SQLException, IOException {
539538
long count = 0;
540539
FileInputStream fileInputStream = null;
541540

542541
try {
543542
Connection unwrap = connection.unwrap(Connection.class);
544543
BaseConnection connSec = (BaseConnection) unwrap;
545-
544+
546545
CopyManager copyManager = new CopyManager((BaseConnection) connSec);
547546
fileInputStream = new FileInputStream(filePath);
548547
count = copyManager.copyIn("COPY " + tableName + " FROM STDIN delimiter ',' csv", fileInputStream);
@@ -594,24 +593,23 @@ The following code is an example for copying in-memory data to table.
594593

595594
```java
596595
private static void inMemory(Connection connection) throws SQLException,IOException {
597-
log.info("Copying inmemory data into table");
596+
log.info("Copying in-memory data into table");
598597
String[] input = {"0,Target,Sunnyvale,California,94001"};
599-
598+
600599
Connection unwrap = connection.unwrap(Connection.class);
601600
BaseConnection connSec = (BaseConnection) unwrap;
602-
601+
603602
CopyManager copyManager = new CopyManager((BaseConnection) connSec);
604-
String copyCommand = "COPY pharmacy FROM STDIN with csv " ;
605-
606-
for (String var : input)
607-
{
603+
String copyCommand = "COPY pharmacy FROM STDIN with csv";
604+
605+
for (String var : input)
606+
{
608607
Reader reader = new StringReader(var);
609608
copyManager.copyIn(copyCommand, reader);
610609
}
611610

612611
copyManager.copyIn(copyCommand);
613-
614-
}
612+
}
615613
```
616614

617615
You can now add the following line in the main method:

0 commit comments

Comments
 (0)