File tree Expand file tree Collapse file tree 2 files changed +63
-1
lines changed
src/main/java/com/eprogrammerz/examples/jdbc/mssql Expand file tree Collapse file tree 2 files changed +63
-1
lines changed Original file line number Diff line number Diff line change 9999 <version >1.1.1</version >
100100 </dependency >
101101
102-
102+ <!-- jdbc mssql-->
103+ <!-- https://mvnrepository.com/artifact/com.microsoft/sqljdbc4 -->
104+ <dependency >
105+ <groupId >com.microsoft</groupId >
106+ <artifactId >sqljdbc4</artifactId >
107+ <version >3.0</version >
108+ </dependency >
103109 </dependencies >
110+
111+ <repositories >
112+ <repository >
113+ <id >Clojars</id >
114+ <name >your custom repo</name >
115+ <url >http://clojars.org/repo/</url >
116+ </repository >
117+ </repositories >
104118</project >
Original file line number Diff line number Diff line change 1+ package com .eprogrammerz .examples .jdbc .mssql ;
2+
3+ import java .sql .Connection ;
4+ import java .sql .DatabaseMetaData ;
5+ import java .sql .DriverManager ;
6+ import java .sql .SQLException ;
7+
8+ /**
9+ * Created by Yogen on 4/4/2017.
10+ */
11+ public class Application {
12+ public static void main (String [] args ) {
13+
14+ /*try {
15+ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
16+ } catch (ClassNotFoundException e) {
17+ e.printStackTrace();
18+ }*/
19+
20+ Connection conn = null ;
21+
22+ try {
23+
24+ String dbURL = "jdbc:sqlserver://localhost:1432;databaseName=abixen-db" ;
25+ String user = "sa" ;
26+ String pass = "Pulch@w2" ;
27+ conn = DriverManager .getConnection (dbURL , user , pass );
28+ if (conn != null ) {
29+ DatabaseMetaData dm = (DatabaseMetaData ) conn .getMetaData ();
30+ System .out .println ("Driver name: " + dm .getDriverName ());
31+ System .out .println ("Driver version: " + dm .getDriverVersion ());
32+ System .out .println ("Product name: " + dm .getDatabaseProductName ());
33+ System .out .println ("Product version: " + dm .getDatabaseProductVersion ());
34+ }
35+
36+ } catch (SQLException ex ) {
37+ ex .printStackTrace ();
38+ } finally {
39+ try {
40+ if (conn != null && !conn .isClosed ()) {
41+ conn .close ();
42+ }
43+ } catch (SQLException ex ) {
44+ ex .printStackTrace ();
45+ }
46+ }
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments