Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
6 replies
Subscribers
4 subscribers
Views
2499 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Plug-Ins
Servlets - DB connect
sandeepg138
over 7 years ago
Hello All,
I am trying to insert a data in db when calling the servlet, it is working fine when in the code i use the connection string of mysql.
But it is not connecting to db, when using the datasource defined in the admin console eg: jdbc/test
Please let me know if the below code used is correct:
connection string
private Connection getConnection() {
Connection connection = null;
try {
Context context = new InitialContext();
DataSource dataSource = (DataSource) context.lookup("java:comp/env/jdbc/test");
connection = dataSource.getConnection();
} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return connection;
}
Regards,
Sandeep
OriginalPostID-253947
Discussion posts and replies are publicly visible
Parents
0
ravinderl352
over 7 years ago
Hey Sandeep, If you want to use data source in servlets/outside Appian, you will have to create the data source in the Jboss. I don't think the data source you have created in Appian admin console can be used in servlet.
You can replicate this issue while defining the DS in appian-ds.xml/through Jboss admin console and then you can verify your servlet code.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
ravinderl352
over 7 years ago
Hey Sandeep, If you want to use data source in servlets/outside Appian, you will have to create the data source in the Jboss. I don't think the data source you have created in Appian admin console can be used in servlet.
You can replicate this issue while defining the DS in appian-ds.xml/through Jboss admin console and then you can verify your servlet code.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data