•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 423,502 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,679 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1296 | Replies: 23 | Solved
![]() |
•
•
Join Date: Apr 2008
Posts: 29
Reputation:
Rep Power: 1
Solved Threads: 0
sorry for annoying, i am quite stupid in it.
i am new to this.
Please help me with this.
my jar file name is mysql-connector-java-5.0.8-bin
Please help me out.
thanks
<html>
<head>
<title>Welcome to the online Auction...</title></head>
<body>
<% try
{
String strUsername = request.getParameter("username");
String strPassword = request.getParameter("password");
Class.forName ("mysql-connector-java-5.0.8-bin");
Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost/user.jsp,admin,admin");
Statement myStatement = myConn.createStatement ();
String strSQL = "SELECT UserName,UserPwd from user where UserName="",UserPwd="";
ResultSet myResult = myStatement.executeQuery(strSQL);
String strUser = myResult.getString("UserName");
String strPass = myResult.getString("Password");
while(myResult.next())
{
if(strUsername.equals(strUser) && strPassword.equals(strPass))
{
out.println("Login Successful!");
}
else
{
out.println("Login Fail!");
}
}
myConn.close();
}
catch(Exception e){}
%>
</body>
</html>
i am new to this.
Please help me with this.
my jar file name is mysql-connector-java-5.0.8-bin
Please help me out.
thanks
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,432
Reputation:
Rep Power: 11
Solved Threads: 295
For once do not use JSP to connect to DB. JSP is for presentation and servlet is for logic. The order should be JSP collect data from user pass it on servlet. Servlet will validate data and if they correct it will attempt to connect to DB. If conection goes well DB operation is processed (insert/update/delete/chceck/retrieve) and servlet retrieve DB respond, after that servlet will either go to next page or return to previous
There is somewhere example how to do it that I posted about 2 years ago and it was recently re-open by somebody
There is somewhere example how to do it that I posted about 2 years ago and it was recently re-open by somebody
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Apr 2008
Posts: 29
Reputation:
Rep Power: 1
Solved Threads: 0
i saw ur code for the connection
am i doing right?
what file shall i save to?
.jsp or.....
public class SomeClassName extends HttpServlet
{
Connection conn;
Statement stmt;
public void init() throws ServletException
{
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch (Exception ex)
{
System.out.println("Exception is : " + ex.toString() );
}
}
public void doPost( HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
try
{
conn = DriverManager.getConnection("jdbc:mysql://localhost/processing.jsp"
+ "visualogic?UserName=admin&UserPwd=admin");
stmt = conn.createStatement();
}
catch(SQLException ex)
{
System.out.println("SQLException : " + ex.getMessage() );
}public class SomeClassName extends HttpServlet
{
Connection conn;
Statement stmt;
public void init() throws ServletException
{
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch (Exception ex)
{
System.out.println("Exception is : " + ex.toString() );
}
}
public void doPost( HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
try
{
conn = DriverManager.getConnection("jdbc:mysql://localhost/processing.jsp"
+ "visualogic?UserName=admin&UserPwd=admin");
stmt = conn.createStatement();
}
catch(SQLException ex)
{
System.out.println("SQLException : " + ex.getMessage() );
}am i doing right?
what file shall i save to?
.jsp or.....
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,432
Reputation:
Rep Power: 11
Solved Threads: 295
•
•
Join Date: Apr 2008
Posts: 29
Reputation:
Rep Power: 1
Solved Threads: 0
i get error for it
here is the error
org.apache.jasper.JasperException: /processing.jsp(1,17) quote symbol expected
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:200)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:150)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:162)
org.apache.jasper.compiler.ParserController.getPageEncodingForJspSyntax(ParserController.java:451)
org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:392)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:173)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:153)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
here is the error
org.apache.jasper.JasperException: /processing.jsp(1,17) quote symbol expected
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:200)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:150)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:162)
org.apache.jasper.compiler.ParserController.getPageEncodingForJspSyntax(ParserController.java:451)
org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:392)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:173)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:153)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,432
Reputation:
Rep Power: 11
Solved Threads: 295
Your connection string
VS
my connection string
Can you explain me what is the purpose of processing.jsp in your code?
•
•
•
•
conn = DriverManager.getConnection("jdbc:mysql://localhost/processing.jsp" + "visualogic?UserName=admin&UserPwd=admin");
VS
my connection string
•
•
•
•
conn = DriverManager.getConnection("jdbc:mysql://localhost/" + "database_name?user=my_username&password=my_password");
Can you explain me what is the purpose of processing.jsp in your code?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,432
Reputation:
Rep Power: 11
Solved Threads: 295
The "processing.jsp" is not supposed to be there. Connection string uses the database URL
Please read through these Java tutorials, just be aware they using Derby database instead of MySQL
jdbc:mysql://localhost/ , database name database_name , database user name UserName=admin and password UserPwd=admin to establish connection with database.Please read through these Java tutorials, just be aware they using Derby database instead of MySQL
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
age amd avatar backup blue gene breach business chips daniweb data data protection database development dos economy energy enterprise europe government hacker hardware hp ibm ibm. news intel ibm it linux medicine memory microsoft news open source openoffice pc ps3 recession red hat russia security server sql sun supercomputer supercomputing survey technology trends ubuntu working x86
- Connect to a database using VB (VB.NET)
- Plz gv me a example(sample code) how to connect the database into the JTable (Java)
- VB: Connect to Access database via ODBC datasource name (Visual Basic 4 / 5 / 6)
- how to connect to database (ASP.NET)
- Can't connect database or view PHP pages in Dreamweaver (PHP)
- Sometimes an error come out "Could not connect to database".Why?? (Oracle)
- How to connect Database in C???? (C)
- submiting info into a database for retrieval! (PHP)
- connect to password protected access db (Visual Basic 4 / 5 / 6)
Other Threads in the JSP Forum
- Previous Thread: jsp
- Next Thread: jsp custom tag



Linear Mode