Jul 6, 2008

Connecting To Sql Server

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP

free web hosting

Connecting To Sql Server

kvarnerexpress
I get the following error while trying to connect to SQL Server using JSP.

Login failed for user 'prashanti'. Reason: Not associated with a trusted SQL Server connection.

My code is as follows:
<html><head></head>
<body>
<%@ page import="java.sql.*" %>
<% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); %>
<% Connection conn = DriverManager.getConnection
("jdbc:microsoft:sqlserver://localhost:1433","prashanti","prashanti");
Statement stmt = conn.createStatement();
ResultSet columns = stmt.executeQuery("select * from employee");
while(columns.next())
{
String name = columns.getString("name");
String address = columns.getString("address");
%>
<%=name%>
<%}%>
</body>
</html>

Any help will be appreciated.

Thanks,

Reply

bjrn
QUOTE(kvarnerexpress @ Jan 30 2005, 12:51 AM)
Login failed for user 'prashanti'. Reason: Not associated with a trusted SQL Server connection.

Okay. I am assuming this isn't on Trap17 because as far as I know we only get MySQL and postgress databases here.

If you have access to the sql server and are allowed to change settings you have to change the authentication mode in the SQL server properties from "Windows only" to "SQL Server and Windows". This is not a java/jsp problem, you would probably get that error with any app you make.

Hope this helps, otherwise google came up with quite a lot of results. Good luck.

Reply

Keeper
I'm using following sintax for connects to the Oracle database from JSP (Tomcat 5.0)
CODE

DbConnectionPool dbpool;
        dbpool = new DbConnectionPool(
 "oracle.jdbc.driver.OracleDriver",
                 "jdbc:oracle:thin:temp/temp@192.168.0.1:1521:temp",
                 "",
                 "");
Connection conn;
Statement stmt;
        conn = (Connection)dbpool.getConnection(20000);

        stmt = conn.createStatement();

and after this text u can use created statment for getting resultsets etc....

CODE

       ResultSet rs = stmt.executeQuery(
        "SELECT * " +
  "FROM table where param1 = '" +
  param1 + "' and  param2 = '" + param2 + " ' ");



Good luck with it... it's for oracle database but i thk creating connections is same in other driver...

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : connecting sql server

  1. Connecting Jsp To Mysql - (4)
  2. Problems With Chat Script - can't encapsulate the chat server... (0)
    hello everyone, I am starting with a project of devloping my own website which could do both
    retreiving data from the database and display it to the registered members along with some
    additional features: namely (chat engine, mailing service and of course discussion forums ) With
    first part of my project nearly completed i am now stuck up with the building of (chat engine,
    mailing service and of course discussion forums ) . I am working with JSP and don't know how to
    really encapsulate the chat server i have build (with rmi ) into JSP.(if any one could guide...)(be...
  3. Web Container - with application server (2)
    Hi there. I've been doing J2EE development for a while. On past projects we have always used the
    three tier approach - web container for presentation logic, application server for business logic
    and oracle/sql server as our data storage layer. My current project entails setting up a J2EE
    architecture for casting votes in an election. It must support multiple access methods like SMS,
    IVR, web, idtv, kiosk. After alot of research on the web there seems to be a trend towards not
    always deploying an application server in your setup. The business logic in our application ...
  4. Blazix - java appln server (3)
    hi friends, Many of u would be using appln server and tomcat is the most popular. But I have come
    across another one which is good for learning purposes. It is called Blazix.. The configuration is
    simple. Just install and then: put jsps and html in one folder and servlets in another. Add a
    servlet config line to the config file and there u r... Actually they are saying that it is very
    fast. Also the size is less than 2 MB. They say on their site that this is due to good algorithms
    and programming practices. But it is worth having a look at: I have cheked jsps and se...



Looking for connecting, sql, server

Searching Video's for connecting, sql, server
advertisement



Connecting To Sql Server



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE