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
5 subscribers
Views
2502 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
sandeepg138
over 7 years ago
datasource name is correct jdbc/test, as for same we are able to insert data throughprocess
So do we need to use this DataSource dataSource = (DataSource) context.lookup("jdbc/test");
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
sandeepg138
over 7 years ago
datasource name is correct jdbc/test, as for same we are able to insert data throughprocess
So do we need to use this DataSource dataSource = (DataSource) context.lookup("jdbc/test");
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data