B4J Question SQL with b4j problem

david13

Member
Licensed User
Hello all,

I'm following the sql tutorial but I can't understand something,

When I run my code, I get this error:
java.sql.SQLException: invalid database address: jdbc:mysql://localhost/db;user=xxx;password=xxx

I added this line:#AdditionalJar: mysql-connector-java-5.0.8-bin.jar

I passed the file in the libraries foldr

I have a sql file that I also put in the libraries folders so I can hv acces to it then I used this line:

sql1.Initialize("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test?characterEncoding=utf8")

I know that I didn't understood exactly ho it works so please can you give me a demo exemple with an sql file.
Thanks
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
hi!

this line is actually right!
B4X:
sql1.Initialize("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test?characterEncoding=utf8")

But this is not appearing in the error.

could you post your code, so we may see where is the error?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
It might sound a silly question, but have you actually installed MySQL on your machine ?
It sounds like you are thinking of SQLite as that is basically just a single file.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

david13

Member
Licensed User
hh, Thanks DonManfred,

I tried to find a complete tutorial on how to use sql with b4j but I just found superficial tutorials,
If I understood, I have to configure the server, can you tell me how? is there any link I can follow?
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
If I understood, I have to configure the server, can you tell me how?

Do you already have mySQL installed?
if that is so, the next step is easy, no need for server configuration beyond users and passwords.

Thake this line for example:
B4X:
sql1.Initialize("com.mysql.jdbc.Driver","jdbc:mysql://localhost/db;user=xxx;password=xxx")

everything is in place if your database is in the same computer you are launching your b4j app, you are only missing the user and password, for the sake of simplicity its better to write it like this

B4X:
    sql1.Initialize2("com.mysql.jdbc.Driver","jdbc:mysql://localhost/db?","user","password")

if you havent installed mysql, we may give you a guidance.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…