Skip to content

Commit

Permalink
Updated formatter to add new line to EOF + formatted project
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra committed Jul 23, 2018
1 parent 9ab00d6 commit e46a6ef
Show file tree
Hide file tree
Showing 69 changed files with 302 additions and 405 deletions.
4 changes: 2 additions & 2 deletions mssql-jdbc_formatter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
Expand Down Expand Up @@ -146,7 +146,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="82"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="18"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/Geography.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,4 @@ private void readPoints() {
points[2 * i] = buffer.getDouble();
}
}
}
}
7 changes: 3 additions & 4 deletions src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,9 @@ private void setTypeDefinition(DTV dtv) {
* generic type info can be used as before.
*/
if (userProvidesScale) {
param.typeDefinition = con.isKatmaiOrLater()
? (SSType.DATETIME2.toString() + "(" + outScale
+ ")")
: (SSType.DATETIME.toString());
param.typeDefinition = con
.isKatmaiOrLater() ? (SSType.DATETIME2.toString() + "(" + outScale + ")")
: (SSType.DATETIME.toString());
} else {
param.typeDefinition = con.isKatmaiOrLater()
? (SSType.DATETIME2.toString() + "("
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public String getColumnName() {
public int getColumnType() {
return javaSqlType;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2445,4 +2445,4 @@ final Object apply(Object value, JDBCType asJDBCType) throws SQLServerException
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ final String getName() {
}

DriverPropertyInfo build(Properties connProperties) {
String propValue = name
.equals(SQLServerDriverStringProperty.PASSWORD.toString()) ? "" : connProperties.getProperty(name);
String propValue = name.equals(SQLServerDriverStringProperty.PASSWORD.toString()) ? "" : connProperties
.getProperty(name);

if (null == propValue)
propValue = defaultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ static String getErrString(String errCode) {
* @param bStack
* true to generate the stack trace
*/
SQLServerException(Object obj, String errText, String errState, StreamError streamError,
boolean bStack) {
SQLServerException(Object obj, String errText, String errState, StreamError streamError, boolean bStack) {
super(errText, errState, streamError.getErrorNumber());

// Log SQL error with info from StreamError.
Expand Down Expand Up @@ -248,8 +247,8 @@ static void makeFromDriverError(SQLServerConnection con, Object obj, String errT
* true to generate the stack trace
* @throws SQLServerException
*/
static void makeFromDatabaseError(SQLServerConnection con, Object obj, String errText,
StreamError streamError, boolean bStack) throws SQLServerException {
static void makeFromDatabaseError(SQLServerConnection con, Object obj, String errText, StreamError streamError,
boolean bStack) throws SQLServerException {
String state = generateStateCode(con, streamError.getErrorNumber(), streamError.getErrorState());

SQLServerException theException = new SQLServerException(obj,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ static final void throwBatchUpdateException(SQLServerException lastError,
throw new BatchUpdateException(lastError.getMessage(), lastError.getSQLState(), lastError.getErrorCode(),
updateCounts, new Throwable(lastError.getMessage()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public interface SQLServerKeyVaultAuthenticationCallback {
* @return access token
*/
public String getAccessToken(String authority, String resource, String scope);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1759,4 +1759,4 @@ public double getZ() {
public double getM() {
return m;
}
}
}
38 changes: 16 additions & 22 deletions src/samples/adaptive/src/main/java/executeStoredProcedure.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/*
* Microsoft JDBC Driver for SQL Server
*
* Copyright(c) Microsoft Corporation All rights reserved.
*
* This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information.
* Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made
* available under the terms of the MIT License. See the LICENSE file in the project root for more information.
*/
package adaptive.src.main.java;

Expand All @@ -20,6 +17,7 @@
import com.microsoft.sqlserver.jdbc.SQLServerCallableStatement;
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;


public class executeStoredProcedure {

public static void main(String[] args) {
Expand Down Expand Up @@ -66,7 +64,8 @@ public static void main(String[] args) {
for (int i = 0; i < 4000; i++)
buffer.append((char) ('A'));

PreparedStatement pstmt = con.prepareStatement("UPDATE Document_JDBC_Sample " + "SET DocumentSummary = ? WHERE (DocumentID = 1)");
PreparedStatement pstmt = con.prepareStatement(
"UPDATE Document_JDBC_Sample " + "SET DocumentSummary = ? WHERE (DocumentID = 1)");

pstmt.setString(1, buffer.toString());
pstmt.executeUpdate();
Expand Down Expand Up @@ -118,26 +117,19 @@ public static void main(String[] args) {
// Handle any errors that may have occurred.
catch (Exception e) {
e.printStackTrace();
}
finally {
} finally {
if (rs != null)
try {
rs.close();
}
catch (Exception e) {
}
} catch (Exception e) {}
if (stmt != null)
try {
stmt.close();
}
catch (Exception e) {
}
} catch (Exception e) {}
if (con != null)
try {
con.close();
}
catch (Exception e) {
}
} catch (Exception e) {}
}
}

Expand All @@ -150,19 +142,21 @@ private static void createStoredProcedure(Connection con) throws SQLException {
+ "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" + " DROP PROCEDURE " + outputProcedure;
stmt.execute(sql);

sql = "CREATE PROCEDURE " + outputProcedure + " @p0 int, @p1 int OUTPUT, @p2 char(50) OUTPUT, " + "@p3 varchar(max) OUTPUT " + " AS"
+ " SELECT top 1 @p1=DocumentID, @p2=Title," + " @p3=DocumentSummary FROM Document_JDBC_Sample where DocumentID = @p0";
sql = "CREATE PROCEDURE " + outputProcedure + " @p0 int, @p1 int OUTPUT, @p2 char(50) OUTPUT, "
+ "@p3 varchar(max) OUTPUT " + " AS" + " SELECT top 1 @p1=DocumentID, @p2=Title,"
+ " @p3=DocumentSummary FROM Document_JDBC_Sample where DocumentID = @p0";

stmt.execute(sql);
}

private static void createTable(Connection con) throws SQLException {
Statement stmt = con.createStatement();

stmt.execute("if exists (select * from sys.objects where name = 'Document_JDBC_Sample')" + "drop table Document_JDBC_Sample");
stmt.execute("if exists (select * from sys.objects where name = 'Document_JDBC_Sample')"
+ "drop table Document_JDBC_Sample");

String sql = "CREATE TABLE Document_JDBC_Sample(" + "[DocumentID] [int] NOT NULL identity," + "[Title] [char](50) NOT NULL,"
+ "[DocumentSummary] [varchar](max) NULL)";
String sql = "CREATE TABLE Document_JDBC_Sample(" + "[DocumentID] [int] NOT NULL identity,"
+ "[Title] [char](50) NOT NULL," + "[DocumentSummary] [varchar](max) NULL)";

stmt.execute(sql);

Expand Down
37 changes: 15 additions & 22 deletions src/samples/adaptive/src/main/java/readLargeData.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/*
* Microsoft JDBC Driver for SQL Server
*
* Copyright(c) Microsoft Corporation All rights reserved.
*
* This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information.
* Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made
* available under the terms of the MIT License. See the LICENSE file in the project root for more information.
*/
package adaptive.src.main.java;

Expand All @@ -19,6 +16,7 @@

import com.microsoft.sqlserver.jdbc.SQLServerStatement;


public class readLargeData {

public static void main(String[] args) {
Expand Down Expand Up @@ -48,8 +46,8 @@ public static void main(String[] args) {
password = br.readLine();

// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://" + serverName + ":" + portNumber + ";" + "databaseName=" + databaseName + ";username="
+ username + ";password=" + password + ";";
String connectionUrl = "jdbc:sqlserver://" + serverName + ":" + portNumber + ";" + "databaseName="
+ databaseName + ";username=" + username + ";password=" + password + ";";

// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Expand All @@ -62,7 +60,8 @@ public static void main(String[] args) {
for (int i = 0; i < 4000; i++)
buffer.append((char) ('A'));

PreparedStatement pstmt = con.prepareStatement("UPDATE Document_JDBC_Sample " + "SET DocumentSummary = ? WHERE (DocumentID = 1)");
PreparedStatement pstmt = con.prepareStatement(
"UPDATE Document_JDBC_Sample " + "SET DocumentSummary = ? WHERE (DocumentID = 1)");

pstmt.setString(1, buffer.toString());
pstmt.executeUpdate();
Expand Down Expand Up @@ -102,36 +101,30 @@ public static void main(String[] args) {
// Handle any errors that may have occurred.
catch (Exception e) {
e.printStackTrace();
}
finally {
} finally {
if (rs != null)
try {
rs.close();
}
catch (Exception e) {
}
} catch (Exception e) {}
if (stmt != null)
try {
stmt.close();
}
catch (Exception e) {
}
} catch (Exception e) {}
if (con != null)
try {
con.close();
}
catch (Exception e) {
}
} catch (Exception e) {}
}
}

private static void createTable(Connection con) throws SQLException {
Statement stmt = con.createStatement();

stmt.execute("if exists (select * from sys.objects where name = 'Document_JDBC_Sample')" + "drop table Document_JDBC_Sample");
stmt.execute("if exists (select * from sys.objects where name = 'Document_JDBC_Sample')"
+ "drop table Document_JDBC_Sample");

String sql = "CREATE TABLE Document_JDBC_Sample (" + "[DocumentID] [int] NOT NULL identity," + "[Title] [char](50) NOT NULL,"
+ "[DocumentSummary] [varchar](max) NULL)";
String sql = "CREATE TABLE Document_JDBC_Sample (" + "[DocumentID] [int] NOT NULL identity,"
+ "[Title] [char](50) NOT NULL," + "[DocumentSummary] [varchar](max) NULL)";

stmt.execute(sql);

Expand Down
41 changes: 15 additions & 26 deletions src/samples/adaptive/src/main/java/updateLargeData.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/*
* Microsoft JDBC Driver for SQL Server
*
* Copyright(c) Microsoft Corporation All rights reserved.
*
* This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information.
* Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made
* available under the terms of the MIT License. See the LICENSE file in the project root for more information.
*/
package adaptive.src.main.java;

Expand All @@ -18,6 +15,7 @@

import com.microsoft.sqlserver.jdbc.SQLServerStatement;


public class updateLargeData {

public static void main(String[] args) {
Expand Down Expand Up @@ -49,8 +47,8 @@ public static void main(String[] args) {
password = br.readLine();

// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://" + serverName + ":" + portNumber + ";" + "databaseName=" + databaseName + ";username="
+ username + ";password=" + password + ";";
String connectionUrl = "jdbc:sqlserver://" + serverName + ":" + portNumber + ";" + "databaseName="
+ databaseName + ";username=" + username + ";password=" + password + ";";

// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Expand Down Expand Up @@ -91,8 +89,7 @@ public static void main(String[] args) {
System.out.println("Updating " + rs.getString("Title"));
rs.updateString("DocumentSummary", "Work in progress");
rs.updateRow();
}
else {
} else {
System.out.println("reading " + rs.getString("Title"));
reader.close();
reader = null;
Expand All @@ -102,42 +99,34 @@ public static void main(String[] args) {
// Handle any errors that may have occurred.
catch (Exception e) {
e.printStackTrace();
}
finally {
} finally {
if (reader != null)
try {
reader.close();
}
catch (Exception e) {
}
} catch (Exception e) {}
if (rs != null)
try {
rs.close();
}
catch (Exception e) {
}
} catch (Exception e) {}
if (stmt != null)
try {
stmt.close();
}
catch (Exception e) {
}
} catch (Exception e) {}
if (con != null)
try {
con.close();
}
catch (Exception e) {
}
} catch (Exception e) {}
}
}

private static void createTable(Connection con) throws SQLException {
Statement stmt = con.createStatement();

stmt.execute("if exists (select * from sys.objects where name = 'Document_JDBC_Sample')" + "drop table Document_JDBC_Sample");
stmt.execute("if exists (select * from sys.objects where name = 'Document_JDBC_Sample')"
+ "drop table Document_JDBC_Sample");

String sql = "CREATE TABLE Document_JDBC_Sample (" + "[DocumentID] [int] NOT NULL identity," + "[Title] [char](50) NOT NULL,"
+ "[DocumentSummary] [varchar](max) NULL)";
String sql = "CREATE TABLE Document_JDBC_Sample (" + "[DocumentID] [int] NOT NULL identity,"
+ "[Title] [char](50) NOT NULL," + "[DocumentSummary] [varchar](max) NULL)";

stmt.execute(sql);

Expand Down
Loading

0 comments on commit e46a6ef

Please sign in to comment.