Meet us at at Real World in Orlando, Florida.
Platforms to show: All Mac Windows Linux Cross-Platform
The class SQLConnectionMBS
class SQLConnectionMBS
MBS Real Studio SQL Plugin (SQL),
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:
Notes: Supported databases: Oracle, Microsoft SQL Server, DB2, Sybase, Informix, InterBase/Firebird, SQLBase, MySQL, PostgreSQL and ODBC and SQLite
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
- event Working
- method AutoCommit as integer
- method Client as integer
- method ClientVersion as integer
- method Commit
- method Connect(DBString as string, UserID as string, Password as string, client as integer=0)
- method Disconnect
- method isAlive as boolean
- method isConnected as boolean
- method IsolationLevel as integer
- method NativeAPI as SQLAPIMBS
- method Option(name as string) as string
- method Rollback
- method ServerVersion as integer
- method ServerVersionString as string
- method SetFileOption(name as string, file as folderitem)
- method SQLExecute(command as string, CommandType as integer=0)
- method SQLExecuteMT(command as string, CommandType as integer=0)
- method SQLSelect(command as string, CommandType as integer=0) as string
- method SQLSelectMT(command as string, CommandType as integer=0) as string
- const kANSILevel0 = 0
- const kANSILevel1 = 1
- const kANSILevel2 = 2
- const kANSILevel3 = 3
- const kClientNotSpecified = 0
- const kLevelUnknown = -1
- const kOptionAPPNAME = "APPNAME"
- const kOptionLibrarySeparator = ":"
- const kOptionWSID = "WSID"
- const kReadCommitted = 1
- const kReadUncommitted = 0
- const kRepeatableRead = 2
- const kSerializable = 3
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 |
|---|---|---|
| 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:
- SQLCommandMBS.Connection as SQLConnectionMBS
- SQLCommandMBS.Constructor(connection as SQLConnectionMBS, SQLCommand as String, CommandType as integer=0)
- PostgreSQLAPIMBS.DB(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.ErrorMessage(conn as SQLConnectionMBS) as string
- SQLDatabaseMBS.GetConnection as SQLConnectionMBS
- PostgreSQLAPIMBS.Host(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.Options(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.Password(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.Port(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.TTY(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.User(conn as SQLConnectionMBS) as string
Some properties using for this class:
Some examples which use this class:
- /SQL/ODBC Connect
- /SQL/Microsoft SQL via ODBC
- /SQL/Web app/SQL
- /SQL/Reporting From A Database/Reports Example with MBS
- /SQL/SQLite Write blob to file
- /SQL/SQLite Version
- /SQL/SQLite Update values
- /SQL/SQLite select version
- /SQL/SQLite Fetch values
- /SQL/SQLite Fetch rows bulk
- /SQL/SQLite ExecuteSQL
- /SQL/SQLite ExecuteSQL with Parameters
- /SQL/SQLite Display Schema
- /SQL/SQLite Connect
- /SQL/SQLite Benchmark vs REALSQLDatabase
- /SQL/SQLDatabaseMBS SQLite select version
- /SQL/SQLDatabaseMBS SQLite Prepared Statement
- /SQL/SQLDatabaseMBS SQLite insert record
- /SQL/SQLDatabaseMBS SQLite Fetch values
- /SQL/SQLDatabaseMBS SQLite ExecuteSQL
- /SQL/SQLDatabaseMBS SQLite Connect
The items on this page are in the following plugins: MBS Real Studio SQL Plugin.
Links
MBS REALbasic Plugins - Bilder aus Nickenich