Connecting on database "MS ACCESS" or "MySQL"
Davide Arrigo
davidearrigo at aliceposta.it
Wed Apr 20 17:49:50 UTC 2005
Alle 23:35, lunedì 18 aprile 2005, bousso at netcourrier.com ha scritto:
> Please I have a problem to connect my application on a database.
> I need a technic or method to connect generally on database an specificlly
> on "MS ACCESS" and "MySQL"
Hy there, yuo can try with something like this to connect your applicatio with
MySql DB, in a workspace:
| connection spec statement resultSet value |
Socket initializeNetwork.
Transcript open.
spec := (JdmConnectionSpec new initialize
user: 'YOUR_USER'; password: 'YUOR_PASSWORD';
host: (NetNameResolver addressForName: 'localhost');
database: 'YOUR_DATABASE';
port: 3306).
connection := JdmConnection on: spec.
statement := connection createStatement.
resultSet := statement executeQuery: 'select * from contatto'. "this is a
query by example in SQL"
"print column names"
Transcript cr; show: (resultSet columns collect: [:col | col name]) asString.
[resultSet next]
whileTrue:
[
value := resultSet valueNamed: 'NOME'. "get column named name"
Transcript cr; show: value printString.
].
connection close.
You must install Mysql Driver by Squeak Package loader.
Best Regards
--
---------------
Davide Arrigo
More information about the Squeak-dev
mailing list
|