Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with JSP Database code

Status
Not open for further replies.

javoine

Programmer
May 22, 2003
25
US
Here is the code i'm trying to execute:

<%@ page import=&quot;java.lang.*&quot; %>
<%@ page import=&quot;java.io.*&quot; %>
<%@ page import=&quot;java.sql.*&quot; %>

<%
DriverManager.getDriver(&quot;jdbc:postgresql://localhost/Databasename&quot;);
Class.forName(&quot;jdbc:postgresql&quot;);
Connection con = DriverManager.getConnection(&quot;jdbc:postgresql://localhost/Databasename&quot;, &quot;Administrator&quot;);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(&quot;SELECT * FROM dates&quot;);
while( rs.next() )
{
out.println( rs.getString( &quot;field&quot; ) );
}
%>

HERE IS THE ERROR IT GIVES:

cannot resolve symbol
symbol : method getConnection(java.lang.String,java.lang.String)
location: class java.sql.DriverManager
Connection con = DriverManager.getConnection(&quot;jdbc:postgresql://localhost/Databasename&quot;, &quot;usrname&quot;);

Any suggestions would be wonderful. the indicator for this error message points to the period before getConnection, like the period is what it cant resolve???

I'm very new to JSP so any help will be appreciated.
Thanx in advance!
 
Look at the docs (there is no method which takes two String arguments) ::

I suspect you want the method which takes a URL, a USER and a PASSWORD :: getConnection(String url, String user, String password)

You may also have probems with :
>> Class.forName(&quot;jdbc:postgresql&quot;);

The Class.forName() method attempts to load a class name, ie ::
Class.forName(&quot;org.gjt.mm.mysql.Driver&quot;).newInstance();

Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top