Problem Connecting to SQL Server(SQL Express Edition) from a JSP page
I'm in the process of developing a web application. to verify the login name and password i tried to connect to the SQL server. but it's not connecting. can somebody give me the steps to connect.
give me the steps to connect.
i am getting the following error
org.apache.jasperException:Exception in JSP welcomeJSF.jsp:15
12 connection con;
13;
14 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
15 Connection con=DriverManager.getconnection
("jdbc:odbc:sqlexpres://localhost:8084:DatabaseName=kk;User=sa;Password=db");
Thanks
I got this error message so much, except it was a little more definitive as i was also informed that "the user was not associated with a trusted connection source".
I came to the conclusion that mssqlexpress was not letting the java app access it as I had no problems accessing mssqlexpress a vb.net or c.net or anyother app developed with a ms product.
I finally went with a msaccess database and mysql on my java host.
Is your message more definitive?
regards,
oh, by the way, specific drivers are needed to access mssqlexpress in the form of .jar files.
jars like msutil.jar,msbase.jar and a few others.
the main one is downloadable from MS.
also check the port number you are using to access the sqlserver.
there is a default port number for local db(1433) and remote db.
hope this helps
regards,
if you copied the code into your question the reason might be as simple as this:
there is no method getconnection in DriverManager. It is getConnection (with a capital c).
Also, did you do a page import on all classes you use that are not in java lang. If not, please use the qualified class names including package names.
It would help to know if this error occurred :
- while generating the java file from the jsp file
- while compiling the generated java file
- during runtime
Did this help ?
> if you copied the code into your question the reason
> might be as simple as this:
> there is no method getconnection in DriverManager. It
> is getConnection (with a capital c).
> Also, did you do a page import on all classes you use
> that are not in java lang. If not, please use the
> qualified class names including package names.
>
> It would help to know if this error occurred :
> - while generating the java file from the jsp file
> - while compiling the generated java file
> - during runtime
>
> Did this help ?
It's a typing mistake. I didn't copy the lines. I am getting the error while compiling the program
yeah there is another mistake in there :
in line 12 you 'declare' a variable con
Connection con ;
in line 15 you declare it again
Connection con = DriverManager.getConnection(...) ;
if this is not another typing error, skip the Connection at the start of line 15 , so that it reads
con=DriverManager.getConnection(...) ;