all. I hope it's not a wired dev-user case. just a simple scenario,if developers want to insert a jsp in AS, the configs (like how to link to the jsp) is set. In the jsp, he wants to create a form and a button. with filling the form and the button click. the data is persisted to mysql. But my question is, how to config MYSQL in the osgi and carbon based manner?
You want to add a MYSQL datasource configuration in to master-datasourcew.xml file and refer that configuration in your code. Also you want to add MYSQL JDBC library in to the AS server as it is not shipped by default. Then it should work. I have implemented similar sample. You can find it here. I deploy a web service (called "MediCom Web Service") in WSO2AS, and it writes and read data from MYSQL database. Please go through sample code and the configuration. Hope this would help you.
Related
I have a web service data control in JDeveloper 12.2.1.3.0 which I show in a table on a page fragment, but I need to filter by one of the attributes and show the filtered data in the table and I don't know how to do that because there is no Named Criteria tab in the data control configuration page.
I looked at the data control configuration file but didn't find any option for adding a filter.
Any help will be really appreciate it, thank you all in advance!
One solution is to call or implement a web service, that returns the data already sorted and/or filtered.
If this can't be done, you have to get the data from the web service in a POJO model and filter/sort it yourself.
I am doing project using jsp in netbeans8.2, tomcat8, java, MySQL(xampp). I have done the coding till multiple file uploads. Now I want to send email to respective user mail id, once file uploads into MySQL database. I searched but on internet but I got for only one user mail id. I need for all users who will upload one or multiple files then immediately mail notification should be sent. Is there any tutorial or suggest me any tutorial(link) that I can refer to solve my problem??
It depends which framework you are using, there are multiple ways to achieve this.
In case you are using Spring Framework use this tutorial
https://www.baeldung.com/spring-email
https://www.javatpoint.com/spring-java-mail-tutorial
In case Plain Java
https://www.baeldung.com/spring-email
Happy to help further as and when needed.
I need to update and insert rows in Sqlite from another app. I am working on an android app and I have to update database of another app,how can I do that,is it possible to access and edit another app's database from my app.
You should look at Content Providers. From the android official docs
Content providers manage access to a structured set of data. They encapsulate the data, and provide mechanisms for defining data security. Content providers are the standard interface that connects data in one process with code running in another process.
Android Docs explain how you can use it.
I understand what you are trying to achieve. correct me if i am wrong. You are developing android application in which you are trying to update your application database by fetching data from some different database. right? if yes, you have to get details of the database server /database connection details from the database owner if possible. in case if the owner of the database is not providing or not ready to give you credentials/database connection details then confirm whether they have any services/webAPI/web services through which they expose database data.
If they have webapi/webservices available then you can easily consume in your andriod application and do what ever operation you want to perform.
Hope this helps..
Since I am new to web application developments, please bear for my silly question.
I am having a scenario wherein the web application want to have a SQLite database inside it.
Also need to access the database with the help of an servlet class/ajax request
I am not sure, its possible or not. please advise me
Is it possible to have a sqlite database inside a application
Id Yes,is it possible to access the same via servlet/ajax request
If yes, is the database will be locally available at client side or not.
Please help me ....!! thanks in advance
yes
access the DB via servlet = bad practice; access it via your java code
the DB is local to the server side not the client, it is not something like HTML5 webstorage
My question is very related to this one: Multiple dynamic data sources for a servlet context. However I haven’t found a proper solution just yet and would like to ask it again.
I have a little JSF application that talks to a MS SQL Server via JDBC. Tomcat is used as the web container. The application retrieves and stores its data from a single database. A login screen is provided. If the credentials match the ones stored in the database then access is granted and I can play around with the application.
Now I would like to add more databases and provide a login screen which not only requests the username and password but the database name as well. Different databases are used because I would like to have some for testing and development. The backup plans are also not the same for every database.
Currently I use JNDI Resources to look up the databases in my code. However this forces me to edit context.xml and web.xml and to restart tomcat. I don’t want to do that. The restart forces me to run around an tell everyone: “Hey I am rebooting do you mind losing all your connections?”
Is the some more dynamic way to do that?
For your purposes, you should really have three separate application server instances (either on three separate machines, or on the same machine listening to different ports, or different host headers etc). The development server instance should always look up the development database, the staging server looks up the staging database etc, and JNDI should be set up to reflect this. That's what JNDI is for.
That said, if you must set things up with just a single application server, you will probably need to look into writing a custom authentication realm that does this. You could either do the actual work of determining which data source to use yourself, or look into something like Hibernate Shards.
Create an array of datasources and let the user select which index in this array you want to use.
I dont know the answer but if you call OSQL -L from JNI you can get a list of available SQL database instances in the area. Then you can connect and get the list of databases within.
So:
user enters username and password
app runs OSQL -L to get the list of instances and provides a select list
user selects instance, jdbc uses credentials in step 1 to get a list of databases from the instance
jdbc uses selected database to connect.
You could get the databases in SQL server using a select statement and eventually discard some of them which are not relevant to your applications.
ResultSet rs = stmt.executeQuery("show databases");