-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5568dd5
commit c72ddba
Showing
13 changed files
with
214 additions
and
75 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/excel2db/service/impl/CreateTableDerbyImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package excel2db.service.impl; | ||
|
||
/** | ||
* Created by Andrey on 6/21/2017. | ||
*/ | ||
|
||
import java.sql.SQLException; | ||
|
||
import excel2db.service.CreateTable; | ||
import excel2db.service.PopulateTable; | ||
import org.apache.poi.ss.usermodel.Sheet; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
public class CreateTableDerbyImpl implements CreateTable { | ||
|
||
public static final Logger logger = LoggerFactory.getLogger(PopulateTableOracleImpl.class); | ||
|
||
private Integer numOfProcessedRows = 0; | ||
|
||
public void createTable(Sheet sheet, String tableName) | ||
throws SQLException { | ||
|
||
logger.info("Create table method : Derby implementation is not covered yet"); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/excel2db/service/impl/DBConnectionDerbyImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package excel2db.service.impl; | ||
|
||
/** | ||
* Created by Andrey on 6/21/2017. | ||
*/ | ||
|
||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
import excel2db.excel2db; | ||
import excel2db.service.DBConnection; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
||
|
||
|
||
|
||
|
||
public class DBConnectionDerbyImpl implements DBConnection { | ||
|
||
// connection parameters | ||
@Value("${db.derby.server}") | ||
String dbServer; | ||
|
||
@Value("${db.derby.user}") | ||
String dbUser; | ||
|
||
@Value("${db.derby.password}") | ||
String dbPassword; | ||
|
||
@Value("${db.derby.port}") | ||
String dbPort; | ||
|
||
@Value("${db.derby.database}") | ||
String dbName; | ||
|
||
|
||
public static final Logger logger = LoggerFactory.getLogger(DBConnectionDerbyImpl.class); | ||
|
||
public void establishDBConnection() { | ||
{ | ||
|
||
try { | ||
excel2db.connection = DriverManager.getConnection( | ||
//"jdbc:derby//" + dbServer + ":" + dbPort + "/" + dbName + ";create=true;user=" + dbUser + ";password=" + dbPassword | ||
"jdbc:derby://localhost:1527/testDB;create=true" | ||
); | ||
|
||
} catch (SQLException e) { | ||
logger.error("Derby Connection Failed! Check output console"); | ||
e.printStackTrace(); | ||
return; | ||
} | ||
if (excel2db.connection != null) { | ||
logger.info("Derby connection is established"); | ||
} else { | ||
logger.error("Failed to make the Derby connection!"); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |
41 changes: 33 additions & 8 deletions
41
src/main/java/excel2db/service/impl/DBConnectionOracleImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,59 @@ | ||
package excel2db.service.impl; | ||
|
||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
import excel2db.excel2db; | ||
import excel2db.service.DBConnection; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import oracle.jdbc.driver.OracleDriver; | ||
|
||
|
||
public class DBConnectionOracleImpl implements DBConnection { | ||
|
||
// connection parameters | ||
@Value("${db.server}") | ||
@Value("${db.oracle.server}") | ||
String dbServer; | ||
|
||
@Value("${db.user}") | ||
@Value("${db.oracle.user}") | ||
String dbUser; | ||
|
||
@Value("${db.password}") | ||
@Value("${db.oracle.password}") | ||
String dbPassword; | ||
|
||
@Value("${db.port}") | ||
@Value("${db.oracle.port}") | ||
String dbPort; | ||
|
||
@Value("${db.database}") | ||
String dbDatabase; | ||
//it could be either sid or service name, | ||
// depending what is provided to connect to the DB | ||
@Value("${db.oracle.sid}") | ||
String dbSid; | ||
|
||
public static final Logger logger = LoggerFactory.getLogger(DBConnectionPostgresImpl.class); | ||
public static final Logger logger = LoggerFactory.getLogger(DBConnectionOracleImpl.class); | ||
|
||
public void establishDBConnection() { | ||
{ | ||
logger.info("Oracle connection is not implemented yet"); | ||
|
||
try { | ||
excel2db.connection = DriverManager.getConnection( | ||
"jdbc:oracle:thin:@//" + dbServer + ":" + dbPort + "/" + dbSid, dbUser, dbPassword) | ||
; | ||
|
||
} catch (SQLException e) { | ||
logger.error("Oracle Connection Failed! Check output console"); | ||
e.printStackTrace(); | ||
return; | ||
} | ||
if (excel2db.connection != null) { | ||
logger.info("Oracle connection is established"); | ||
} else { | ||
logger.error("Failed to make the Oracle connection!"); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.