MBS Xojo Developer Conference and Training
Join us from 11th to 14th September 2013 in Koblenz.

Platforms to show: All Mac Windows Linux Cross-Platform

SQLConnectionMBS class

class, SQL, MBS Real Studio SQL Plugin (SQL), class SQLConnectionMBS,
Plugin version: 9.3, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: The class for a SQL Plugin Database connection.
Example:
dim con as new SQLConnectionMBS

try

// where is the library?
con.SetFileOption con.kOptionLibraryMySQL, SpecialFolder.UserHome.Child("libmysqlclient.dylib")

// connect to database
// in this example it is Oracle,
// but can also be Sybase, Informix, DB2
// SQLServer, InterBase, SQLBase and ODBC

dim server as string = "192.168.1.80:3306@test"

con.Connect(server,"root","",SQLConnectionMBS.kMySQLClient)

MsgBox "We are connected!"

// Disconnect is optional
// autodisconnect will ocur in destructor if needed
con.Disconnect

msgbox "We are disconnected!"

catch r as RuntimeException
MsgBox r.message

// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try

// on error rollback changes
con.Rollback

catch rr as runtimeexception
MsgBox rr.message
end try
end try
Notes: Supported databases: Oracle, Microsoft SQL Server, DB2, Sybase, Informix, InterBase/Firebird, SQLBase, MySQL, PostgreSQL and ODBC and SQLite

Isolation Levels

Constant Value Description
kANSILevel0 0 ANSI Level 0
kANSILevel1 1 ANSI Level 1
kANSILevel2 2 ANSI Level 2
kANSILevel3 3 ANSI Level 3
kLevelUnknown -1 Unknown
kReadCommitted 1 Read committed.
kReadUncommitted 0 Read uncommitted.
kRepeatableRead 2 Repeatable read.
kSerializable 3 Serializable.

Values for autocommit property

Constant Value Description
kAutoCommitOff 0 Autocommit is off.
kAutoCommitOn 1 Autocommit is on.
kAutoCommitUnknown -1 Autocommit unknown

The database client constants

Constant Value Description
kClientNotSpecified 0 Client is not specified.
kDB2Client 6 DB2 client.
kFirebirdClient 4 InterBase/Firebird client.
kInformixClient 7 Informix client.
kInterBaseClient 4 InterBase/Firebird client.
kMySQLClient 9 MySQL client.
kODBCClient 1 ODBC client.
kOracleClient 2 Oracle client.

For Windows the file is "oci.dll", for Linux libclntsh.so and for Mac OS X libclntsh.dylib.
kPostgreSQLClient 10 PostgreSQL client.
kSQLBaseClient 5 SQLbase client.
kSQLiteClient 11 SQLite client. Or spatialite.
kSQLServerClient 3 Mircosoft SQL Server client.

You may need to download the client packages for accessing SQL Server. Files like the SQLNCLI dll may be missing. You can download for example the Feature Pack for Microsoft SQL Server 2005 from the microsoft download page.
kSybaseClient 8 Sybase client.

Options to specify the library with SetFileOption

Constant Value Description
kOptionLibraryDB2 "DB2CLI.LIBS" for DB2.
kOptionLibraryFirebird "IBASE.LIBS" for Firebird.
kOptionLibraryInformix "INFCLI.LIBS" for Informix.
kOptionLibraryInterbase "IBASE.LIBS" for Interbase.
kOptionLibraryMySQL "MYSQL.LIBS" for MySQL. Library extension on Mac is ".dylib", on Linux ".so" and on Windows ".dll". You get this library with the MySQL download on their homepage.
kOptionLibraryODBC "ODBC.LIBS" for ODBC.
kOptionLibraryOracle "OCI8.LIBS" for Oracle.
kOptionLibraryPostgreSQL "LIBPQ.LIBS" for Postgre SQL.
kOptionLibrarySQLBase "SQLBASE.LIBS" for SQLbase.
kOptionLibrarySQLite "SQLITE.LIBS" for SQLite. Can also be the spatialite library.
kOptionLibrarySybaseComn "SYBCOMN.LIBS" for Sybase.
kOptionLibrarySybaseCS "SYBCS.LIBS" for Sybase.
kOptionLibrarySybaseCT "SYBCT.LIBS" for Sybase.
kOptionLibrarySybaseIntl "SYBINTL.LIBS" for Sybase.
kOptionLibrarySybaseTCL "SYBTCL.LIBS" for Sybase.

This class has no sub classes.

Some methods using this class:

Some properties using for this class:

Some examples which use this class:


The items on this page are in the following plugins: MBS Real Studio SQL Plugin.




Links
MBS Real Studio Plugins