-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>cool.scx</groupId> | ||
<artifactId>scx</artifactId> | ||
<version>3.1.7</version> | ||
</parent> | ||
|
||
<artifactId>scx-jdbc-sql-server</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>SCX JDBC SQL Server</name> | ||
<url>https://github.com/scx567888/scx</url> | ||
<description> | ||
SCX JDBC SQL Server | ||
</description> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>scx-jdbc</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<!-- sql server 驱动 --> | ||
<dependency> | ||
<groupId>com.microsoft.sqlserver</groupId> | ||
<artifactId>mssql-jdbc</artifactId> | ||
</dependency> | ||
|
||
<!-- ****************** 以下为测试依赖 ****************** --> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>scx-logging</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
74 changes: 74 additions & 0 deletions
74
scx-jdbc-sql-server/src/main/java/cool/scx/jdbc/sql_server/SQLServerDialect.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,74 @@ | ||
package cool.scx.jdbc.sql_server; | ||
|
||
import com.microsoft.sqlserver.jdbc.SQLServerDataSource; | ||
import com.microsoft.sqlserver.jdbc.SQLServerDriver; | ||
import cool.scx.jdbc.JDBCType; | ||
import cool.scx.jdbc.dialect.DDLBuilder; | ||
import cool.scx.jdbc.dialect.Dialect; | ||
|
||
import javax.sql.DataSource; | ||
import java.sql.Driver; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
public class SQLServerDialect extends Dialect { | ||
|
||
private static final SQLServerDriver DRIVER = initDRIVER(); | ||
|
||
private static SQLServerDriver initDRIVER() { | ||
return new SQLServerDriver(); | ||
} | ||
|
||
@Override | ||
public boolean canHandle(String url) { | ||
try { | ||
return DRIVER.acceptsURL(url); | ||
} catch (SQLException e) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean canHandle(DataSource dataSource) { | ||
try { | ||
return dataSource instanceof SQLServerDataSource || dataSource.isWrapperFor(SQLServerDataSource.class); | ||
} catch (SQLException e) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean canHandle(Driver driver) { | ||
return driver instanceof SQLServerDriver; | ||
} | ||
|
||
@Override | ||
public String getFinalSQL(Statement statement) { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public DDLBuilder ddlBuilder() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public DataSource createDataSource(String url, String username, String password, String[] parameters) { | ||
var sqlServerDataSource = new SQLServerDataSource(); | ||
sqlServerDataSource.setURL(url); | ||
sqlServerDataSource.setUser(username); | ||
sqlServerDataSource.setPassword(password); | ||
return sqlServerDataSource; | ||
} | ||
|
||
@Override | ||
public JDBCType dialectDataTypeToJDBCType(String dialectDataType) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String jdbcTypeToDialectDataType(JDBCType jdbcType) { | ||
return ""; | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
scx-jdbc-sql-server/src/main/resources/META-INF/services/cool.scx.jdbc.dialect.Dialect
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 @@ | ||
cool.scx.jdbc.sql_server.SQLServerDialect |
9 changes: 9 additions & 0 deletions
9
scx-jdbc-sql-server/src/test/java/cool/scx/jdbc/sql_server/test/Test.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,9 @@ | ||
package cool.scx.jdbc.sql_server.test; | ||
|
||
public class Test { | ||
|
||
public static void main(String[] args) { | ||
|
||
} | ||
|
||
} |
Empty file.