mssql connection problem

2009-02-02 Thread Ashis

Hello all,
   i have problem regarding mssql connection

/*Code Snippet for MSSQL connection***/
public static Connection getSqlConnection() throws SQLException {
   try {
   Context c = new InitialContext();
   DataSource dataSource = (DataSource)
c.lookup(java:/comp/env/jdbc/mssql);
   return dataSource.getConnection();
   } catch (NamingException err) {
   throw new SQLException();
   }
   }

I got a SQLEXCEPTION in getSqlConnection() function:
*javax.naming.NameNotFoundException: cannot create resource instance


/*Code Snippet of context path for MSSQL connection***/  
Resource
   name=jdbc/mssql
   type=net.sourceforge.jtds.jdbcx.JtdsDataSource
   removeAbandoned=true
   removeAbandonedTimeout=60
   maxActive=4
   maxIdle=2
   username=sa
   password=root
   maxWait=5000
   driverClassName=net.sourceforge.jtds.jdbc.Driver
  url=jdbc:jdts:sqlserver://localhost:1433/flight /


How can i remove this sql exception?
Looking forward to your suggestion.
Thank you

-- 
View this message in context: 
http://www.nabble.com/mssql-connection-problem-tp21787078p21787078.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: mssql connection problem

2009-02-02 Thread Dipu
this is how my code looks

/**
 * Grab Update SQL Connection
 *
 * @return
 * @throws NamingException
 * @throws SQLException
 * @throws SQLException
 */
public Connection getConnection() throws NamingException, SQLException
{
Context env = (Context) new 
InitialContext().lookup(java:comp/env);
DataSource obj_datasrc = (DataSource) env.lookup(jdbc/);  

return obj_datasrc.getConnection();
}


and this is my context xml looks

Context
Resource name=jdbc/
   auth=Container
   type=javax.sql.DataSource
   maxActive=5
   maxIdle=2
   maxWait=1
   removeAbandoned=true
   removeAbandonedTimeout=60
   logAbandoned=true
   username=xxx
   password=xxx
   driverClassName=net.sourceforge.jtds.jdbc.Driver
   
url=jdbc:jtds:sqlserver://xxx.xxx.xxx.xxx:port;DatabaseName=db_name/
/Context


hope this helps

cheers
dipu

On Mon, Feb 2, 2009 at 10:10 AM, Ashis chettri.as...@gmail.com wrote:

 Hello all,
   i have problem regarding mssql connection

 /*Code Snippet for MSSQL connection***/
 public static Connection getSqlConnection() throws SQLException {
   try {
   Context c = new InitialContext();
   DataSource dataSource = (DataSource)
 c.lookup(java:/comp/env/jdbc/mssql);
   return dataSource.getConnection();
   } catch (NamingException err) {
   throw new SQLException();
   }
   }

 I got a SQLEXCEPTION in getSqlConnection() function:
 *javax.naming.NameNotFoundException: cannot create resource instance


 /*Code Snippet of context path for MSSQL connection***/
 Resource
   name=jdbc/mssql
   type=net.sourceforge.jtds.jdbcx.JtdsDataSource
   removeAbandoned=true
   removeAbandonedTimeout=60
   maxActive=4
   maxIdle=2
   username=sa
   password=root
   maxWait=5000
   driverClassName=net.sourceforge.jtds.jdbc.Driver
  url=jdbc:jdts:sqlserver://localhost:1433/flight /


 How can i remove this sql exception?
 Looking forward to your suggestion.
 Thank you

 --
 View this message in context: 
 http://www.nabble.com/mssql-connection-problem-tp21787078p21787078.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org