Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Databases > Re: trouble con...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 11 Topic 3700 of 3784
Post > Topic >>

Re: trouble connecting to mysql

by naveen <naveen.cse217@[EMAIL PROTECTED] > Apr 8, 2008 at 07:05 PM

> > though i have tried putting database as //localhostneo also
> >  but this didnt work too

well i am soory ..my mistake i meant //localhost/neo


> <%
> Class.forName("com.mysql.jdbc.Driver");
> Connection con =
> DriverManager.getConnection("jdbc:mysql://localhost/Test", "", "");
> Statement stmt = con.createStatement();
> ResultSet rs = stmt.executeQuery("SELECT * FROM T1");
> ...
>
> works for me.

well i have used:
________________________________________________________
....
<%
String varSql = request.getParameter("sql");
if (varSql == null) {
    varSql = "";
}
varSql = java.net.URLDecoder.decode(varSql).trim();
%>
....
<%
String dbURL="jdbc:mysql://localhost/neo";
String username="root";
String passwd="abc";
try{
 Class.forName("com.mysql.jdbc.Driver");
 Connection conn=DriverManager.getConnection(dbURL,username,passwd);
 Statement stat=null;
 try{
  stat=conn.createStatement();
  if(varSql.length() !=0 ){
%>
    <pre> <%= varSql %> </pre>
<%
 if (stat.execute(varSql)) {
 java.sql.ResultSet rs = stat.getResultSet();
	 try {
          java.sql.ResultSetMetaData metaData = rs.getMetaData();
          int colCount =metaData.getColumnCount();
%>
....
________________________________________________________

now i must be making a mistake somewhere since the browser shows this:

_____________________________________________________
An Exception was caught while connecting to the database.

 java.sql.SQLException: Communication link failure:
java.io.IOException, underlying cause: Unexpected end of input stream

** BEGIN NESTED EXCEPTION **

java.io.IOException
MESSAGE: Unexpected end of input stream

STACKTRACE:

java.io.IOException: Unexpected end of input stream
	at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:1096)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:626)
	at com.mysql.jdbc.Connection.createNewIO(Connection.java:1562)
	at com.mysql.jdbc.Connection.(Connection.java:491)
	at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:
346)
	at java.sql.DriverManager.getConnection(Unknown Source)
	at java.sql.DriverManager.getConnection(Unknown Source)
	at org.apache.jsp.HelloMysql_jsp._jspService(HelloMysql_jsp.java:98)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
393)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
320)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
290)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
230)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
175)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
128)
	at
org.apache.catalina.valves.ErrorRe****tValve.invoke(ErrorRe****tValve.java:
104)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
109)
	at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
261)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
844)
	at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:581)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:
447)
	at java.lang.Thread.run(Unknown Source)
____________________________________________________

what should i do about this?
please help
 




 11 Posts in Topic:
trouble connecting to mysql
naveen <naveen.cse217@  2008-04-06 10:03:41 
Re: trouble connecting to mysql
=?ISO-8859-1?Q?Arne_Vajh=  2008-04-06 15:07:58 
Re: trouble connecting to mysql
Lew <lew@[EMAIL PROTEC  2008-04-06 15:54:55 
Re: trouble connecting to mysql
naveen <naveen.cse217@  2008-04-07 02:28:27 
Re: trouble connecting to mysql
=?ISO-8859-1?Q?Arne_Vajh=  2008-04-07 21:40:57 
Re: trouble connecting to mysql
"joeNOSPAM@[EMAIL PR  2008-04-07 09:23:31 
Re: trouble connecting to mysql
naveen <naveen.cse217@  2008-04-08 19:05:48 
Re: trouble connecting to mysql
=?ISO-8859-1?Q?Arne_Vajh=  2008-04-08 22:24:21 
Re: trouble connecting to mysql
naveen <naveen.cse217@  2008-04-09 06:02:49 
Re: trouble connecting to mysql
Lew <lew@[EMAIL PROTEC  2008-04-09 19:52:50 
Re: trouble connecting to mysql
naveen <naveen.cse217@  2008-04-10 11:56:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 6:53:31 CDT 2008.