MS SQL JDBC connection

버전 1.6.0.0 (3.22 KB) 작성자: Oleg Komarov
Establishes JDBC connection to MS SQL Easier to use than "database(…)" NEW! Windows authentication
다운로드 수: 2.3K
업데이트 날짜: 2009/11/10

라이선스 보기

MSSQLconn establishes a JDBC connection with MS SQL.
This function handles better the inputs and the error msgs than the database function.

MSSQLCONN(DBNAME, USERPASSMETHOD,OPTIONAL1...3) full syntax
- dbname: database name to which you want to connect (char format)
- userpassmethod --> {'username','password'}; 1st cell username,2nd cell password
- userpassmethod --> '-win'; use windows authentication (only for R2008b)
- userpassmethod --> '-manual'; supply credentials through inputdlg
- servername: string with the server where the database is hosted
- portnumber: integer of the port
- oldversion: if MS SQL is older than 2005 ed. supply '-old';
Only dbname is mandatory. Only one method to supply username and password is accepted at one time. Optionals can be supplied in any order and combination.

[OUT,SETTINGS] = ...
- Class 'database': connection to the server.
- Class 'structure' with the settings used to connect (except password).

DEFAULT SETTINGS:
- user = '';
- pass = '';
- server = 'localhost';
- port = 1433;
- driver = 'com.microsoft.sqlserver.jdbc.SQLServerDriver' (MS SQL 2005 and above);
- windows authentication: false;

Examples:
- MSSQLconn('MyDB') % use the whole set of default settings
- MSSQLconn('MyDB',{'Oleg','****'}) % supply username and password
- MSSQLconn('MyDB',{'Oleg',''}) % supply just the username, password by inputdlg
- MSSQLconn('MyDB','-win') % use windows authentication
- MSSQLconn('MyDB','-manual') % supply both username and password through inputdlg
- MSSQLconn(...,'myserver') % supply servername with any combination of dbname and userpassmethod
- MSSQLconn(...,1433, 'myserver','-old') % full set of optionals

Installing the driver:
1) If you don't have the drivers package download it from:
http://msdn.microsoft.com/en-us/data/aa937724.aspx
This page explains which driver fits your case.
2) Add the path of the .jar driver manually (better) to:
"matlabroot\toolbox\classpath.txt"
3) Check with "javaclasspath" (cmd pane) if the driver has been added correctly.
4) To be able to use windows credentials with '-win' userpassmethod, add just the directory where the .dll is to:
"matlabroot\toolbox\librarypath.txt"
The .dll is contained in the JDBC driver package. For more details:
http://www.mathworks.com/support/solutions/en/data/1-9SHNAT/

Comments/suggestions/error reports are welcome.

If other DBMS connection are required, plz write at oleg.komarov@hotmail.it.

p3v4

인용 양식

Oleg Komarov (2025). MS SQL JDBC connection (https://kr.mathworks.com/matlabcentral/fileexchange/25577-ms-sql-jdbc-connection), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2009b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.6.0.0

Added windows authentication feature, changed syntax and edited description.

1.5.0.0

Corrected some minor bugs and reorganized some code.

1.4.0.0

Added: single input syntax and screenshot. Edited description.

1.1.0.0

Edited description; added link to FEX MSSQLconn in the help part of the function

1.0.0.0