Java Applet needs to read MySQL - mysql

I have a Java Applet hosted online which is merrily reading data from CSV files.
However my host has MySQL and I'd like to start read/writing a database instead.
I'm happily accessing MySQL on my home PC with Java (NOT an Applet) via JConnector.
For starters the jar file mysql-connector-java-5.1.18-bin.jar needs uploading to my web server right?
When running my own database-accessing programs from NetBeans I added this jar file to the Netbeans project "Libraries". When compiling/running from command prompt I used "-classpath".
However, an Applet runs on an html page not Netbeans nor DOS! Therefore: by what mechanism do we convey the location of the Driver .jar file to the Applet?
Many thanks, Robin.

An applet should not be directly accessing the DB. Instead it should be forced to go through server-side functionality (JSP, servlet, ASP etc.) that mediates what it can & cannot do.
For either the applet or the server-side mediated solution, the mysql-connector-java-5.1.18-bin.jar will need to be on the run-time class-path. For a servlet/JSP, that would be by putting it into (from memory) WEB-INF/lib. For an applet, added to the archive attribute of the applet element.

Related

Jhipster: Making a WAR file with client-configurable Datasource

My development team is working on a web application and has assigned me to research on how to make a client-side WAR file with a configurable Datasource.
This is the first commercial project of ours:
Language: Java / JavaScript(jQuery and AngularJS) / HTML / CSS
Database: MySQL
Development Tool: IntelliJ
Automation System: Gradle
Application Generator: JHipster
Version Control: SourceTree
At this time, our client has agreed to simply deploying the app on his own Amazon Web Server's MySQL database using an executable file (currently, a WAR file) delivered by us in a safe USB.
So far, the WAR file can be made with JHipster and deployed with no issue on our internal server. However, we did hard-code all the database-connection (JDBC) stuffs in a YML file under src/main/resources/config.
Naturally, our client has a database with totally different schema, usernames, and passwords. And the WAR file we are about to give him cannot be executed unless the datasource specs in there match his.
Because source codes cannot be extracted from a WAR, the client is not going to modify the datasource from his end. At the same time, he does not fancy giving us datasource information.
Thus, we are to come up with, quote, an executable file which allows him to configure the datasource the first time it is executed on his AWS.
Is there a way we can achieve this while not straying too far from the current deployment method (WAR file)?
Nothing specific to JHipster here, it's purely a Spring Boot question. You can either provide an application-prod.yml external to your war file or keep it internal but use placeholders referring to environment variables defined in your client server.
For more details, read the Spring Boot doc https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

How could I automatically upload files from my directory to server? [duplicate]

An ASP.NET application (running on Windows server/IIS 7) has to transfer big size files uploaded by current user to an external SFTP server. Due to the file size the idea is to do this asynchronously.
The idea is that the ASP.NET application stores the uploaded file on a local directory of the Windows server. The current user can continue his work. A Windows service or a Quartz job (other tools(*)/ideas?) is now responsible to transfer the file to the external SFTP server.
(*) Are there existing tools that listen on changes of a Windows directory and then move the files on a SFTP server (incl. handling communication errors/retries)?
If there is no existing solution, do you have had similar requirements? What do we have to consider? Because the connection to the SFTP server is not very stable we need an optimized error handling with auto retry functionality.
To watch for changes in a local directory in .NET, use
the FileSystemWatcher class.
If you are looking for an out of the box solution, use the keepuptodate command in WinSCP scripting.
A simple example of WinSCP script (e.g. watch.txt):
open sftp://username:password#host/
keepuptodate c:\local_folder_to_watch /remote_folder
exit
Run the script like:
winscp.com /script=watch.txt
Though this works only, if the uploaded files are preserved in the remote folder.
(I'm the author of WinSCP)

Connect Xamarin.forms with MySQL

I know about xamarin connection with SQLite but it is locally
I need to connect my remotely MySQL database with xamarin.forms (I know about the security issue of this without using web services layer, but i will only use it for my own work)
This plugin is for xamarin.iOS and Xamarin.Android
I cannot add it using dependency service because i cannot add this component to the shared project
So is there any example of connecting MySQL database with xamarin.forms
You can't add references to your shared library. Shared libraries act like a list of files that are directly included in the project. The advantage of shared projects is just, that you do not have to maintain these included files for each project that uses code of the contained files. See the Xamarin documentation for further explanation.
What you have to do, if you want to consume a 3rd party libray within a shared library: Add the library to each project that uses the shared library (e.g. your iOS and Android project)
2ct to the mentioned security issue
You are right about the security issue. That's why I'd advice against, using mysql directly from your app. (I'll explain it for other readers that aren't aware of this problem and stumble over this question)
You should tunnel it through HTTPS because:
Some networks just block certain ports (HTTP and HTTPS are usually not blocked)
You publish your credentials with your app either statically or dynamically, but the credentials to your database are interceptable either way. You should authenticate a user and not an app. So there should be some kind of authentication / authorization that is revokeable. There was a nice talk from Kerry Lothrop on the Xamarin Evolve 2016 on this topic. https://www.youtube.com/watch?v=uLFtQHNxGaI

Is there a way to use an MS Access DB (MDB files) on Azure Websites?

We normally use Microsoft.ACE.OLEDB.12.0 to read and write from MS Access Databases. On a normal Server you can just install office or the AccessDatabaseEngine_x64.exe and this works fine.
Now we want to move our app to Azure (Preferably the Azure Websites and not WebRole or full VM). But there we obviously can't install the Access Drivers.
Is there another way to use Access on Azure? Maybe a 3rd party driver or something that can be run/installed with user privileges.
We looked at dotConnect, but as far as I understand, this still needs OLE DB.
Switching to Azure SQL is not an option, as Access is used as a "FileType" for a 3rd Party system that we use.
Specifically for a cloud service, you can do the following:
Create a cloud service that wraps your core project/site.
Include the MDB in the project that is wrapped from (1). Many ways to do that.
Include any executables or scripts you want to be deployed as well. You can add them to a Visual Studio project and set their Build Action to Content.
In the project that is wrapped, include a WebRole.cs file and implement RoleEntryPoint and specifically implement public override bool OnStart(). This will allow you to run scripts, move files on the file system etc.
The nice thing about using WebRole.cs to run your initialization code is that when Azure reimages your cloud service, the code will always run and get the machine back to a known state.

Saving Glassfish JDBC Configuration

I recently had to re-install Glassfish 3.1.2 from scratch and I found myself spending way too much time re-configuring the JDBC Connection Pools and Resources (copy/paste from another source was not an option). Many applications use the server and there are plenty of things to remember when configuring JDBC connectivity.
Is there a way to "save" the Glassfish JDBC configuration to a file so that I can easily upload it to a new version of the server (or a new server in another machine) without losing my sanity again? A quick hack would also be highly appreciated as well!
Server scoped application resources are stored in the domain.xml file within the <resources> element. There are <jdbc-resource> and <jdbc-connection-pool> elements which store your connections. From my experience you can copy those elements from one domain.xml file to another (at least for all 3.x versions of Glassfish).
Application scoped resources can be stored in glassfish-resources.xml files which need to go into the META-INF dir for an EAR and in WEB-INF for a WAR. They will be deployed together with an application and can only be accessed by this application. More information here.