I have a project in vb.net and another in android studio I want to link them with one database (real time connection) what is the best way to do that (sql server-my sql ....other?)
Sql server is pretty easy to link to vb.net. you simply create a connection string with the server name and password, although I am not sure about android, but the process would probably be similar
It looks like you want to communicate between the two applications via SQL server, is that correct? While it is possible to do this it is highly ill-advised as the communication cannot be realtime (you would have to poll a table by selecting from it every ## seconds or use triggers MSSQL / MySQL in a very strange way) and it is likely to be unnecessary.
My suggestion is to consider what data you need to go back and forth and why. It is unusual for an Android app to directly connect to a database across the Internet because of the security risks in exposing a database publicly. Most developers opt to use a web application of some kind that provides an API for the Android app to consume. This prevents direct access to the database and provides you a place to add in all your business/game/other logic.
What I'm trying to do is connect a Java Android app with a FireBird database that is stored in an enterprise server.
I realised i need to use some kind of webserver to avoid connecting to the database directly.
In other words, something like this:
Android app -> WebServer -> Database
My problem is that although there are plenty of examples none of them let me do it.
Where can I find a full example of making the webserver, retrieve data (images, datasets, etc.) and how to connect my clients to it.
And obviously if there is a better way to do what I need that I'm not aware of.
Thanks in advance.
I have created a java servlet with which I have attached SQL database. Android client is sendig data to java servlet to save it in database which is working fine. I want to know if multiple android clients will share the same database connection or do i need to do some threading or something else?
Regards,
In my opinion You should synchronize databases on Android devices with servlet. Synchronization is not easy to make. I don't found ready class or library for it.
Maybe you find something on stackoverflow ;-)
I am trying to develop a real-time Android application where all contents are stored in server. So, they are available whenever a connection to Internet is available. Also, the application provides communication between users and conversations are stored in the server as well. Nothing is locally stored.
However, I am still cannot decide which database type I can use. I intended to use SQLite but I am not sure if I can really use it or not.
Could you please guide me to the proper database type to my application.
Appreciate your time and efforts.
As its upto you which database you use.
you may Install Lamp (For Linux) or WAMP(for window) . This is a nice database tool and very easy to handle and easy linked with PHP for various database function
I recently developed something similar to what you are talking about and here is what I would suggest you to go for.
Use SQL server to manage the data on your desktop and create a web-service in .Net on Visual Studio.
(Note that as others have already mentioned, it really does not matter what is the database you are using in your server end, because eventually the data is going to come to the Android application from the server in form of either xml or json in the web-service., regardless of what database you are using. So it is totally your wish which database you want to use.)
Then connect to the web-service in your application and set/get data from the remote Database, using SOAP.
Link on how to make a web-service in .NET (does not include the implementation in Android).
Links on how to connect your service with Android : this, this and this.
Is there any sample? I have my android application and I need to connect to mysql server on my machine, what is the best way?
I should not use jdbc, explanation here
Best way to implement Client <-> Server <-> Database architecture in an Android application?
Never never use a database driver across an Internet connection, for any database, for any platform, for any client, anywhere. That goes double for mobile. Database drivers are designed for LAN operations and are not designed for flaky/intermittent connections or high latency.
And should go for:
DefaultHttpClient httpclient = new DefaultHttpClient();
But there is no example in how to open a connection or execute a simple sql statement.
anyone could help me?
You should either use web services or implement an HTTP handler and transfer in a RESTful manner.
I'm a fan of Offline First, meaning your app should be usable without a connection.
To facilitate this, I would recommend using a SQLite local database, and syncing to a remote database when online.
You can use a tool like SymmetricDS or Daffodil Replicator to sync your local and remote databases over HTTP(S).
In order to connect to a MySQL server, you need a MySQL client. Android does not come with any MySQL libraries. You may be able to take a generic Java MySQL library and fudge it to work with Android, but that would be a big undertaking and wasted time.
The link you pointed to already told you that what you're trying to do is wrong in the first place. Don't connect to a database across the internet! You will need something on your server that responds to HTTP requests, looks up data in the database, and sends them back via HTTP. The link already mentioned a few options. You could even write something yourself, although it's most likely easier to use an existing solution than trying to make your own approach safe and hack-proof.
I tried to connect DatabaseServer from an Android Application,initially i faced some issue while i was using jtds, jar package for database Driver Support, instead of using jtds jar file use mysql-Connector jar file for Database Driver Support.
mysql-connector jar file "mysql-connector-java-5.1.24-bin.jar".
put this jar file in projects libs folder.
a little bit code snippet :
`String url="jdbc:mysql://(IP-of databaseServer):3306/DBNAME";`
`String driver="org.gjt.mm.mysql.Driver";`
`String username="XYZ";//user must have read-write permission to Database
`String password= "*********";`//user password
`try{
Class.forName(driver).newInstance();//loading driver
Connection con = DriverManager.getConnection(url,username,password);
/*once we get connection we can execute ths SQL command to Remote Database Server with the help mysql-connector driver over Internet*/
}`
`catch(Exception e){
e.printStackTrace();
}`
I hope it could work.
Cheers
Rajesh P Yadav.
You won't be able to connect directly to a MySQL database with the HttpClient, as the MySQL database doesn't operate on that protocol.
The second part of the answer to the question you linked recommends going with web services and consuming those to communicate with the database server. Which is exactly what you would be able to do with the HttpClient.
If you need to share data between multiple phones, I would recommend exposing it as a web service. If the data only needs to be accessible on that particular phone (and you want to remain relational) you can use sqlite.