I have recently put all my java EE projects into my google drive so i can access them on my laptop and desktop computer. Some of my projects have a database component which I have the database stored in a MySQL server. Is there a way that I can export this database and just access it from like a database file which I can store in my project file so I can use it on both my laptop and desktop computer?
This is really what I would like:
-Be able to work on my java EE projects that have a database on both my computers
-Store my MySQL Server databases in a file which can go in my project folder then use java to access that database instead of going through the server
Any alternate ways of doing this would help me out this is just one way I can think of doing.
Note: I am using my laptop on the go so my desktop computer wont always be accessible from my laptop neither will I have an active internet connection always.
Thanks
Install MySQL on your laptop, then transfer database using backup/restore, e.g. using mysqldump. See https://dev.mysql.com/doc/refman/5.0/en/backup-and-recovery.html
Im working with a SQLite database right now, and I've made a javaFX application (I will call it the client) that allows me to work with it, but I need to work with it remotely as well. From what I've read SQLite does not support remote acces, so I have 2 choices:
Creating another application in the server that receives input from the client through a socket, and it modifies the SQLite database. (The problem with this, is that the server is a webserver and I dont have SSH access, so I can upload the server side application on the server, but I cant start it...)
(I dont know if this works) Create a java application that runs on the server, and you load it through a browser such as chrome or firefox. From what I've seen java webstart allows you that, but I don't if the app runs on the server or on your computer (meaning that you won't have acces to the SQLite database as well).
If someone here has some knowledge on this pls share, I need to know if I can make this work, and if not, what other options I have.
I don't think SQLite is designed for that. If you use SQLite because it's small and easy, why don't you try JavaDB (derby), it is included in your JDK distribution and you can use it embedded in your app or as a database server (not both of course).
I developed an application with a java db database .I cannot access the database records when I close the netbeans IDE with the message "Error connecting to server Localhost on port..." My connection code to the Database is :
String host="jdbc:derby://localhost:1527/Employee;create=true";
String user="admin";
String pass="admin";
con=DriverManager.getConnection(host,user,pass);
How do I fix the problem?
Netbeans automatically starts the Derby server; you can see that in the "Services" tab (Ctrl-5).
You'll have to start the database server by hand if you don't use Netbeans; see the doc.
Presumably your Derby database is hosted in NetBeans? You'll need to create a standalone database.
You would have to probably start your database before connecting (you are using server mode). Have a look into Vogella tutorial on Derby db connection from java application: http://www.vogella.de/articles/ApacheDerby/article.html
I guess NetBeans has an embedded DB instance.
Try to use
jdbc:derby:/MyFolder/MyDatabase/Employee;create=true
or
jdbc:derby:C:\MyFolder\MyDatabase\Employee;create=true
if you do not need to access the DB from multiple applications.
You can use JavaDB (aka Derby) either by connecting to a JavaDB Network Server or by using it as an embedded DB when your application opens the DB files itself.
Currently, your application is connecting to a Network Server started by NetBeans, as your URL is telling to connect to port 1527 on localhost, i.e. your system.
What you need to do is tell your application to use JavaDB as an embedded database, i.e. it should manage the database itself instead of getting Netbeans to do it instead. You can do this just be changing the URL to something like:
jdbc:derby:Employee;create=true
You may need to tweak that URL depending on where the database files are stored relative to your application's working directory.
Only one application can have the DB open at one time. So when you're doing this NetBeans won't be able to open the database, and if NetBeans has the database open your application won't be able to open it. So you may find you want to reconfigure NetBeans as a DB client.
the simplest way of dealing with these problems is creating batch files..
first of all build your java database program.. the tricky part is to start the server. the jderby is a server so it needs to be started.. that's why you start the server in netbeans. so download db derby files from "http://db.apache.org/derby/releases/release-10.8.2.2.html". after you download these files, copy your netbeans project in those db jderby files.. go and copy your database folders from where they will be saved.. and paste them in the db jderby files.. now open notepad and type
#echo
start (PATH)
start (PATH)
the first path take the path of the file named start network server.bat
the second path take the path of the jar file of your main project.
Now save your the notepad as setup.bat and run the batch file afterward.. and ur program will start the server and running your application at once...
NB: you can use a different name from setup, any of your choice but the extension bat must be available
This is the first time I am going to deploy the Java Desktop Application with MS Access DB and discovered JAR package is not getting database access other then my development PC though I had the MS access DB in the same directory of the JAR file I have copied after Build the application. And I understand that I cannot connect MS access DB I created with ODBC connection of my PC. Now my question is
How can I deploy Java Desktop Application with MS access BD which will run in any computer where manual ODBC connection to the MS ACCESS DB for every computer will not require ?
I am not trying to connect MS access DB within a net work rather I am trying run this app where MS Access DB is already installed and my supplied DB will be with the JAR file and I want to access the DB I have provided from Java Front End Application.
Please help.
First you should get ODBC driver for Access database. Some computers may don't have it.
After you install that driver you should create ODBC Data Source on computer. I have no idea how to do it in Java, but ODBC Data Source configurations are stored in registry and you can add your Data Source.
Google "registry add odbc data source" or "Can I Create and Delete a DSN Using a Script" (second one is title of good article i found.
Probably you can access registry from java without any problems.
You can also use one of install-maker programs. Some of them have something like "Add Data Source" functionality.
I want to place a server program written in Java on the cloud. It would accept TCP socket connections from clients (clients are android phones using 3G), do some computations, save stuff to a MySQL database (also on EC2), and send stuff back to the clients over the TCP connections. It may even be necessary to create several instances of the server (i.e. a process group).
Is this easy to do? I think I can make a AMI, but I'm not sure how to upload Java files, compile and run them, and create a MySQL database etc
Any help would be much appreciated.
Take a look at using Amazon Elastic Beanstalk. Beanstalk is Amazon's PaaS offering and it will alleviate a lot of the system administration burden. Here's a quick description from their docs:
AWS Elastic Beanstalk is an even
easier way for you to quickly deploy
and manage applications in the AWS
cloud. You simply upload your
application, and Elastic Beanstalk
automatically handles the deployment
details of capacity provisioning, load
balancing, auto-scaling, and
application health monitoring.
Also, if you're interested in using MySQL then you should look at Amazon RDS. Again, this will alleviate the system administration burden for your database tier. Here's a quick description from their docs:
Amazon Relational Database Service
(Amazon RDS) is a web service that
makes it easy to set up, operate, and
scale a relational database in the
cloud. It provides cost-efficient and
resizable capacity while managing
time-consuming database administration
tasks, freeing you up to focus on your
applications and business.
Is this easy to do? I think I can make
a AMI, ...
I think the answer depends on how comfortable you are with system administration in general. Creating a AMI to run in EC2 is really pretty much the same as creating a physical server or a VM image. You'll need to install an operating system, and then install tools, libraries and programs you need (like mysql, the jdk, ssh, etc).
You can save yourself a little work by using one of Amazon's pre-built AMI's http://aws.amazon.com/amis/. But, ultimately, you'll be responsible for all system administration of the server. If you've never built a server from the ground up, you have a pretty big learning curve ahead of you. It's not insurmountable, but just be warned that the devil is in the details; there's a ton of stuff you'll need to learn ;-)
... but I'm not sure how to upload Java
files, compile and run them, ...
Once the server is setup and running in EC2, compiling them and running java files is just the same as compiling and running on your local. Normally, you probably want to compile and package your java app into a jar or war and then transfer that up to your EC2 server. If you install linux os on your EC2 server, you can use scp or a FTP client to transfer your files over sftp to move the files from your local up to the server. Once the latest files are up on your server, you can ssh to the server and start your app.
... and create a MySQL database etc ...
Installing mysql is going to be specific to the OS you choose to install on your server. For example, you can install mysql easily on Ubuntu with a command like:
sudo aptitude install mysql
Again, there will be more system-admin-type stuff to learn here specific to mysql databases.
So, it's definitely doable. An experienced sys admin could build a AMI instance pretty easily/quickly. If this is your first experience with system administration, I'd suggest finding an old Desktop you have lying around and try installing Ubuntu and all the required libraries and tools you need (mysql, jdk, ssh, etc..). Get your java program working on the old desktop and then it should be pretty easy to create an AMI from that. Then you can run your custom AMI on EC2 and will be set up.
If you don't have a spare desktop lying around, you can use one of the Virtual Machine products like VMWare Player or Sun's VirtualBox and build a server instance on one of those.
If you want to avoid the hassle of managing the entire install of the Operating system, you might want to look at services like slicehost and/or linode instead of EC2. They give you ssh access to a pre-installed server. And it's as easy as clicking a button to install programs like mysql, etc.
Hope this answer is relevant and helpful, good luck.
- Dave
If you can use Tomcat as your server - you might want to try Amazon Web Services Elastic Beanstalk It will greatly simplify your task by providing an easy instance of Tomcat to deploy.
EDIT: AWS has a full section on how to develop using Java here: http://aws.amazon.com/java/
How comfortable are you with remote administering a server and solving problems most people have never heard of? That's what you're talking about.
You'll create your EC2 instance, log into it and configure it like you would any other server you're working with. You can download JDKs to it, dbs etc. You might consider using a tool like Chef to help you. You'll use ftp and scp to copy files to the server.
You're probably going to want your Java server on one box and have it talk to a separate db server since you say you may want multiple servers.
Once the server is working the way you like it you can create an image of it to use to launch multiple instances, then configure a load balancer to point at your servers.
If you can create a MySql db on your local box you can create it in the cloud. If not?....
Running Applications needs app. s/w to run them.
Apps such as Cyber Duck helps to upload files via SFTP.
I am successful in doing the same problem addressed.. Trust me, YOU CAN DO IT. All u need is interfaces for server services such as MySQL (use WorkBench to connect using key pair), terminal access (using PUTTY/SSH via MAC) and well you are good to go
I think to get started is to use a a whole unit packed into one archive.
Think of it as you have your Java files compiled, a embedded http server say tomcat. Now all of this packed in a jar ready to be deployed on Amazon's EC2. Use this link for more on embedded servers and relevant code.
As far as database is concerned, you can use Amazon's RDS. You can configure mysql on RDS and obtain a link to it for connection. Amazon RDS would help you to get started with database.
Now that you have everything ready to start and work with application. Now is the time to deploy on Amazon AMI
Perform Following steps to deploy you app on Amazon EC2:
Create a server instance on Amazon EC2 refer EC2 getting started.
Receive Private key file i.e. .pem(receive from Step 1), this file would help you to login to your server instance and perform SFTP.
Use Putty or similar SSH client to login to your EC2 server instance created on Step-1 using .pem file and server's public DNS, refer Accessing Instance for SSH login.
Transfer the archived files packed into jar to server using SFTP client, WinnSCP being one such client, refer SFTP for more on it.
Run application. Note in case of jar file you can simply fire java -jar TomcatApp.jar.
If everything is configured properly you would be to access the app using EC2 instance's public DNS or public IP, which would be of the form:
http://<public_dns_address>:<port number>/servlet
Hope it helps you to get started and provide you an overall view.