forked from Acxiom/metalus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Acxiom#345 JDBC DataRow(Reader|Writer)s are now working.
- Loading branch information
Showing
13 changed files
with
436 additions
and
67 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
metalus-core/src/main/scala/com/acxiom/metalus/connectors/Connector.scala
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
12 changes: 12 additions & 0 deletions
12
metalus-core/src/main/scala/com/acxiom/metalus/sql/jdbc/JDBCUtils.scala
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,12 @@ | ||
package com.acxiom.metalus.sql.jdbc | ||
|
||
import java.sql.{Connection, DriverManager} | ||
import java.util.Properties | ||
|
||
object JDBCUtils { | ||
def createConnection(uri: String, properties: Map[String, String]): Connection = { | ||
val props = new Properties() | ||
properties.foreach(entry => props.put(entry._1, entry._2)) | ||
DriverManager.getConnection(uri, props) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
metalus-core/src/main/scala/com/acxiom/metalus/sql/jdbc/package.scala
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,18 @@ | ||
package com.acxiom.metalus.sql | ||
|
||
import java.sql.ResultSet | ||
|
||
package object jdbc { | ||
implicit class ResultSetImplicits(rs: ResultSet) { | ||
def map[R](func: Int => R): Iterator[R] = Iterator.from(0).takeWhile(_ => rs.next()).map(func) | ||
|
||
def toList: List[Map[String, Any]] = { | ||
val columns = (1 to rs.getMetaData.getColumnCount).map(rs.getMetaData.getColumnName) | ||
new Iterator[Map[String, Any]] { | ||
def hasNext: Boolean = rs.next() | ||
|
||
def next(): Map[String, Any] = columns.map(c => c -> rs.getObject(c)).toMap | ||
}.toList | ||
} | ||
} | ||
} |
Oops, something went wrong.