Where does JSC store user/password for connecting to a database
When writing my webapp in JSC i test it on a local mysql database, but when i want to deploy to a production server, it has a different database name, user name and password.
How do i modify this in the war file that java studio creator generates. I can see no file that contains any reference to a user/pass for the database, just the data source name everywhere.
How do jsc webapps connect to the database if they dont set the user/pass anywhere?
[467 byte] By [
PDeva1a] at [2007-11-27 2:20:28]

# 1
Add this to your server.xml file of your deployment server:
<Host name="testurl.com" appBase="webapps/MyApp">
<Alias>www.testurl.com</Alias>
<Context path="" docBase=".">
<Resource name="jdbc/dbname" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="mypwd" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/dbname?autoReconnect=true"/>
</Context>
</Host>
Watch out, make sure you try reaching your application through the specified URL.
Hope this helps.
Kind regards
Frederik
# 2
> How do i modify this in the war file that java studio
> creator generates. I can see no file that contains
> any reference to a user/pass for the database, just
> the data source name everywhere.
> How do jsc webapps connect to the database if they
> dont set the user/pass anywhere?
JSC created apps use JNDI. If you expand Data Source References node in projects tab you will see all data sources needed by your application. To get things working on your deployment server, you must konfigure jdbc data sources and register them in JNDI.
For example if your application references data source "MyDataBase" then your deployment server needs datasource stored with JNDI name "jdbc/MyDataBase", otherwise you'll get NamingException. Check your app server docs for information how to do this.
For design time JSC creates its own datasources in Servers tab (notice that they have same name as references in your project) and deploys them to bundled SunAppServer.
best regards
Grzegorz