B4J Question jRDC2 config.properties

Alexander Stolte

Expert
Licensed User
Hello community, i have a problem, because i dont understand what i insert into 2 columns.

I have looked every tutorial, about it here, in the forum. The most user are using MySql, but i have a MS Sql Database. So, now to my Question.

In the file "config.properties" exist the column "DriverClass" and JdbcUrl"

DriverClass: I should specify the location where the driver is located? So it would look like this? : "C:\Program Files\Microsoft JDBC Driver 6.0 for SQL Server\sqljdbc_6.0\deu\jre8\sqljdbc42.jar"

JdbcUrl: and here the path where the jRDC.jar file located? Looks like: C:\Users\Administrator\Desktop\jRDC.jar

thanks for help. :)

My first post without translator jay :cool:
 

EnriqueGonzalez

Well-Known Member
Licensed User
The driver class is not the location of your jar.

Actually the location should be inside your b4j installation folder there is a folder called libraries, there you must copy your jar and add it your project like this:

B4X:
#AdditionalJar: sqljdbc42.jar

Then the jdbc URL is the address and instance of your SQL server itself. As you may see in the post I shared.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
It is better to configure the additional libraries folder (Tools - Configure Paths) and put it there.
I had already the "sqljdbc42.ja" in the additional folder packed.
#AdditionalJar: sqljdbc42.jar
I had that already :)

If I understood correctly, it would look like this:
DriverClass: com.microsoft.sqlserver.jdbc.SQLServerDriver
And
JdbcUrl: sqlserver://TOSHIBA-PMSMC\SQLEXPRESS:1433
config.PNG


But what ist that for parameters?: "TOSHIBA-PMSMC" is that the ip from my root server? or the name of the root server?

that confuses me:
B4X:
jdbc:sqlserver://xxxyyy.database.windows.net:1433
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Hi!

TOSHIBA-PMSMC this and this
xxxyyy.database.windows.net:1433

Are the same, the physical location of your database, one is represented as the name of the computer and the other one as the DNS address of an azure site.

Your address could also be:
192.168.1.100
Localhost
Yoursite.com

For these to work you must have your SQL server TCP protocol enabled and always be sure that you are calling the right port. Default port is 1433

The name of the database is the next one with the question mark
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Take this example

POS2GOSRV\POS2GOSQL:1433\defDB?

Pos2gosvr is the physical address, this time is a named computer within your LAN, this is the default protocol for SQL server, if you want to access it via IP you have to enable it

Pos2gosql is the instance name within the computer. Most of the time you have 1 instance only. Some people have 2 one for full fledged SQL server and other one for sqlexpress

DefDb? Is the name of the database if you omit this part the SQL server connection will open like SQL studio where you can see all your databases.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
i think i have it. I hope so..

B4X:
JdbcUrl=jdbc:sqlserver://localhost\H2628730\administrator:1433\Test

"localhost" because the jdbc runs on my root server.(the same server as the database)

"H2628730\administrator" is the servername + current user

"1433" the default port, this works

"Test" is the database
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Almost!

User is not declared here.

Use only one of this 2:
H2628730 or localhost ( I always use local host)

What is the name of the instance?? If you have SQL studio is the one that its on the corner below your connect button and above the databases. It may be SQL2014 or SQLexpress
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
It's the first one not the second.

JdbcUrl=jdbc:sqlserver://localhost\SQLEXPRESS:1433\Test

you may encounter a whole different issue regarding the user. The driver you downloaded will not accept windows users. You should create a user of SQL server
 
Upvote 0

Alexander Stolte

Expert
Licensed User
thats now my config file:
B4X:
#DATABASE CONFIGURATION
DriverClass=com.microsoft.sqlserver.jdbc.SQLServerDriver
#JdbcUrl=jdbc:mysql://localhost/test?characterEncoding=utf8
JdbcUrl=jdbc:sqlserver://localhost\SQLEXPRESS:1433\Test

User=sa

Is there a command to test the whole?
 
Upvote 0

Alexander Stolte

Expert
Licensed User
i think i have a issue in my b4a code or so, because he said me that:
B4X:
reqManager.Initialize(Me, "http://serverip/rdc")

he cant found "/rdc"

but it comes from b4a, wrong threat here.
B4X:
** Service (httputils2service) Start **
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

<title>404 - File or directory not found.</title>

<style type="text/css">

<!--

body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}

fieldset{padding:0 15px 10px 15px;}

h1{font-size:2.4em;margin:0;color:#FFF;}

h2{font-size:1.7em;margin:0;color:#CC0000;}

h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}

#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;

background-color:#555555;}

#content{margin:0 0 0 2%;position:relative;}

.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}

-->

</style>

</head>

<body>

<div id="header"><h1>Server Error</h1></div>


<div id="content">

 <div class="content-container"><fieldset>

  <h2>404 - File or directory not found.</h2>

  <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>

 </fieldset></div>

</div>

</body>

</html>

Error: Not Found

But perhaps it is familiar to you.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
If you want to know if your server is up and running with the connection to your database working.

i believe that you are lacking the port that is configured in your config too.

open a browser and put this url
B4X:
'in your config files
#Java server port
ServerPort=17178

'in your browser
http://myIpServer:17178/test

It should give you confirmation.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
not in germany :confused:

so i install b4j now on the server and the logs said:

B4X:
Waiting for debugger to connect...
Program started.
2017-05-05 18:34:24.367:INFO::main: Logging initialized @695ms
Mai 05, 2017 6:34:24 PM com.mchange.v2.log.MLog
INFORMATION: MLog clients using java 1.4+ standard logging.
Mai 05, 2017 6:34:24 PM com.mchange.v2.c3p0.C3P0Registry
INFORMATION: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2017-05-05 18:34:25.138:INFO:oejs.Server:main: jetty-9.3.z-SNAPSHOT
2017-05-05 18:34:25.200:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@335eadca{/,file:///C:/Users/Administrator/Desktop/jRDC/Objects/www,AVAILABLE}
2017-05-05 18:34:25.203:INFO:oejs.AbstractNCSARequestLog:main: Opened C:\Users\Administrator\Desktop\jRDC\Objects\logs\b4j-2017_05_05.request.log
2017-05-05 18:34:25.856:INFO:oejs.ServerConnector:main: Started ServerConnector@6ee52dcd{HTTP/1.1,[http/1.1]}{0.0.0.0:17178}
2017-05-05 18:34:25.856:INFO:oejs.Server:main: Started @2189ms
Emulated network latency: 100ms
jRDC is running (version = 2.1)
 
Upvote 0
Top