You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ashis <ch...@gmail.com> on 2009/02/02 11:10:04 UTC

mssql connection problem

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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: mssql connection problem

Posted by Dipu <di...@googlemail.com>.
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/xxxx");		
		return obj_datasrc.getConnection();
	}


and this is my context xml looks

<Context>
	<Resource name="jdbc/xxxx"
			   auth="Container"
			   type="javax.sql.DataSource"
			   maxActive="5"
			   maxIdle="2"
			   maxWait="10000"
			   removeAbandoned="true"
                           removeAbandonedTimeout="60"
                           logAbandoned="true"
			   username="xxxxxxx"
			   password="xxxxxxx"
			   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 <ch...@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: mssql connection problem

Posted by Martijn Dashorst <ma...@gmail.com>.
What does this have to do with Wicket? Read [1] and especially the
part about "Choose your forum carefully" [2]

Martijn

[1] http://www.catb.org/~esr/faqs/smart-questions.html
[2] http://www.catb.org/~esr/faqs/smart-questions.html#forum

On Mon, Feb 2, 2009 at 11:10 AM, Ashis <ch...@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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