JavaDatabase Source

Note: The function DesktopFolder is deprecated in Xojo. You can replace it with SpecialFolder.desktop.

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /kunden/ on line 244
Class App
Inherits Application
// Constants
Const kFileQuitShortcut = Ctrl+Q
Const kFileQuit = E&xit
Const kEditClear = &Delete

// Event implementations
Sub Open()
dim j as JavaDatabaseMBS
dim r as JavaRecordSetMBS
dim f as FolderItem


j=new JavaDatabaseMBS(f,"com.mysql.jdbc.Driver")

if j.Connect then
MsgBox "connected"

'j.ExecuteSQL "CREATE DATABASE mytest"
'if j.Error then
'MsgBox j.ErrorString
'end if

j.ExecuteSQL "USE mytest"

'j.ExecuteSQL "CREATE TABLE mytable(test_id int, test_val char(15) not null, PRIMARY KEY (test_id))"
'if j.Error then
'MsgBox j.ErrorString
'end if

'j.ExecuteSQL "INSERT INTO mytable(test_id, test_val) VALUES(1,'One')"
'j.ExecuteSQL "INSERT INTO mytable(test_id, test_val) VALUES(2,'Two')"
'j.ExecuteSQL "INSERT INTO mytable(test_id, test_val) VALUES(3,'Three')"
'j.ExecuteSQL "INSERT INTO mytable(test_id, test_val) VALUES(4,'Four')"
'j.ExecuteSQL "INSERT INTO mytable(test_id, test_val) VALUES(5,'Five')"
'if j.Error then
'MsgBox j.ErrorString
'end if

r=j.SelectSQL("SELECT * from mytable",true)
if r<>Nil then
while r.NextRecord
MsgBox str(r.getInt("test_id"))+" "+r.getString("test_val")

end if

if j.Error then
MsgBox j.ErrorString
end if
MsgBox "Failed to connect"+EndOfLine+j.ErrorString+EndOfLine+str(j.Errorcode)

end if
End Sub
End Class

Class Window1
Inherits Window
End Class

Watch other Xojo videos:

ThumbnailMBS Xojo Plugins 21.1


23:12 minutes
ThumbnailInstalling a Xojo Web App Server


28:19 minutes
ThumbnailMBS Plugin Installation Win


22:03 minutes
ThumbnailMBS Plugin Installation Mac


25:17 minutes
ThumbnailXDC 2020 MBS Plugins Presentation


38:59 minutes
ThumbnailMBS Plugins @ MBS 2019


42:28 minutes

MBS Xojo Plugins

Start Chat