using html5 standalone app using deskshell to connect to mysql - mysql

I am making small standalone html 5 application using deskshell, I want to use MySQL database. How can I connect from JavaScript to MySQL without using PHP or server side language?

This is definitely possible using deskshell. It can be a little confusing as to what is the server and what is the client etc. Generally it is much simpler than you at first think.
I suggest the following approach. Deskshell uses an unmodified nodejs binary. So to make life simpler begin by first installing node (so it sets up everything like paths etc for you). Then use npm - the node package manager to install a module that will allow you to connect to mysql. You can go to the npm website and search for mysql. When you find a package you can npm install packagename. You can remove then afterwards with npm remove packagename. (Check website for exact syntax).
So using this approach and copying and modifying the examples from the modules homepage you should be able to get nodejs to connect to mysql and run some queries.
The next step is then to add this "database ability" to your application. Here you should realise you have 2 javascript engines running. You have one "sandboxed" v8 js engine running in the chrome browser and you then have a second "unsandboxed" v8 nodejs that will run your app.js file. I find the simplest and most pleasing way to connect the two is to use a websocket to send messages from one v8 to the other. Then you can decide the level of abstraction to write your little api at. So you could write all logic in the browser scripts, send the sql ocer the socket, nodejs app.js script then recieves message, queries mysql and returns results as json. An alternative would be you ask the api for 20 user objects and it turns the request into sql and executes it for you and returns it to the browser.
You will need to copy the node_modules/packagename folder to your application directory as node_modules/packagename. In addition you may need to change your deskshell code from require ("packagename") to be require ("./path/to/package/folder")
I would suggest you look at using sqlite3 as your database engine if a separate server is not used for your application. This is because sqlite3 is a file based in process database so you do not have to run a server process on the end users machine. However if you are connecting to an existing server database then mysql is the better option.

Related

WAMP MYSQL or MYSQL service on clients side?

We have designed an application using .NET framework. There is a client application and a server application. The client applications, webpages, android/ iphone applications fetch data from the server using the WCF service.
My issue here is that some of the data that can be set by the user on the application is being saved on the server but cannot does not reflect on the client side once the application is restarted, we have designed the application in such a way that every change on the client side will be reflected on the server side, this is done to make this a cloud based application.
Some of the settings changed or value input on the client side is updating on the server successfully but does noes reflect on the client machines using the direct MYSQL service. However there are absolutely no issues while using WAMP as the MYSQL service, i.e the clients using the WAMP server can see the changes made. We have tried matching the versions and also have tried new and old versions of the standalone MYSQL. Firewall settings all seem fine. Since we prefer to install the standalone MYSQL over WAMP on our customers machines, it would be great if you could shed some light on the possible issues. Is there any difference in the initial config of MYSQL and the default config of WAMP MYSQL.
Hence if there is any thing in particular to note or tweak in this regards it will be really helpful.
Thanks in advance.
I don't think you'll get a really good answer to your question, because the term "WAMP" does not refer to a specific package, but rather any package that includes Windows versions of Apache, MySQL and PHP (and sometimes Perl instead of or in addition to PHP). See this link for a list of some of the available packages:
http://en.wikipedia.org/wiki/Comparison_of_WAMPs
Those packages come with different standard configurations for MySQL. Since you didn't say which WAMP package (and version) you were using, there is no way of knowing in what way their standard configuration differs from a plain MySQL installation (where the version is also important)
Have you tried just running a diff on the respective config files?

How do I allow a user to install MySQL on a user's machine more easily so they can connect to it via a Java application?

Let's say I have written an application in Java that is programmed to use a MySQL database. The user of the Java application needs to have MySQL on their machine in order for the application to work.
What can I do to make sure that the user has the correct version of MySQL on their machine and if they don't then install it so they can properly run the Java application?
Note: I had sent some links to setup Java and MySQL for a business analyst of a program I am working on and he was not able to decipher the madness that is installing MySQL. He is not computer technical and wouldn't even know what to enter into the forms of the MySQL installation. What could I do to ease this task for the end user?
Update: Unfortunately, for security reasons that are a requirement for this project we have to use MySQL and not SQLite or Derby. Unless there is a way to make sure that no one deletes the SQLite database file or switches it out for another one. We need to guarantee data integrity and I find that using MySQL gives me the best chance at doing that.
What is the target platform?
Assuming something UNIXish, you can either:
1) Include a shell script to download, install, and setup mysql. Complicated, but not impossible.
2) Use an embedded Derby database. On my current project, we have a version where the user can just "download and go." That version uses an embedded Derby database that writes to a file, similar to hsqldb or sqlite3. Any of those are fine options.
The easiest thing for the user is to embed the database in the Java application. No setup required. There's MySQL OEM (not free), so you might consider switching to SQLite instead, which is the de facto standard embedded database. (See this question for more on that.)

Package Java web app along with jboss, mysql and activemq for deployment

I have a springframework web application that uses JBoss, MySQL and ActiveMQ.
At the moment, I have to install and configure JBoss, MySQL and ActiveMQ and JBoss manually.
What is the best way to package the application so a user can maybe do a one click install (on Linux platform, maybe Windows too?)
The "proper" way to do it is to pull down the source or src.rpms (or the equivalent of src.rpms depending on your distro) and repackage them correctly. If you have never messed with packaging linux application then this will probably take you a long time and will yield mediocre results unless you are willing to invest a lot of time.
An easier method is to write a shell script. Copy every shell command you type into a .sh file and run that file as a privileged user. If you edit files manually (with vim, emacs or gedit) instead edit the files with perl, sed, and awk, or just crush the files by curl'ing the modified version from a local webserver or copied from scp.
You can include the commands to install the packages as well as configure them in the script if you like.
As far as ActiveMQ is in question, you can always embed it in your application. Take a look at http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html for more info

Local use of MySQL database

Is it possible to use MySQL local? I mean NOT at a server. I read a lot about MySQL on a webserver with PHP, Joomla etc.
I want to program a piece of software and use a database local to store results. Can I use MySQL for that?
If so, is ther anyware on the net a good tutorial how to do that?
You can install MySQL on your workstation, it doesn't need to be on a "server" per se. You still need to use something that can connect to it. From a Java application, for instance, you'd use JDBC; from .Net, you'd probably use ADO.Net; etc.
As far as I know, it will still want to have its server process (mysqld) running and for you to connect to that process via sockets and the like; there's no standard in-process version that I'm aware of. (The server can be listening only on the local interface, though.) There are several alternatives if you want in-process stuff, such as SQLite and HSQLDB.
Of course, if you're feeling really enterprising, there's the open source version of MySQL, which means you could compile it into your app (if you're using C or something that can link to it), but I suspect that's going rather too far. :-)
Yes, works like a charm for this.
Mysqls homepage has lots of info for this.
use SQLite. it is a popular embedded database.
It can be deployed via XCopy and no server installs.
But it can only be used locally. i.e if you later on decide to allow remote access, then you will need to migrate it to MySQL or other databases.
Try xampplite - it will painlessly install MySQL for you (on your local windows machine) as well as apache, php and a few other web apps if you need them.
If you don't want to install a server, you may be interested into Sqlite! It's the most widely deployed embedded database, and it's Public Domain.
http://www.sqlite.org/
Firebird is also an alternative. It's fully ACID-compliant and runs under the Interbase Public License.
http://www.firebirdsql.org/

load the mysql driver in android emulator

how to load the mysql server in android emulator
i.e
Class.forName("com.mysql.jdbc.Driver")
i got the exception java.land.ClassNotFoundException in com.mysql.jdbc.Drive
please reply me.
This assumes MySQL is publicly available from internet, but it is never good idea .
Setup public WebService and connect to it from mobile application.
You won't be able to run MySQL server on an Android device.
What you're doing, however, is trying to load the MySQL client library. That isn't included as part of Android so you cannot load it. You'd need to include the relevant JARs in your project, if you really do want to connect to a remote MySQL database from an Android app.
If you do want to store and access data on your Android device, the awesome SQLite database is included by default, including all the APIs you need to create, upgrade and otherwise interact with SQLite databases.
When I did this I created PHP files for the database operations. I sent data in XML and received data in XML all using PHP scripts. I found this to be the easiest way for me...but you need to know PHP of course.