Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials


 

 

Struts Tutorials

Struts Resources

Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Jdbc Understanding Common Sql Stateme

User Comments
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl
  Blink   Furl   Simpy   Y! MyWeb 

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

4 comments so far (post your own) View All Comments Latest 10 Comments:

Can anybody help me?

import java.sql.*;
public class connect {
static Connection conn;

static Statement DataRequest;
static ResultSet Results;

public static Connection getConnection()
{
// TODO Auto-generated constructor stub

Connection conn=null;
try
{

Class.forName("com.ibm.db2.jcc.DB2Driver");
System.out.print(" ");
System.out.println("LOADED DB2 DRIVER");//Driver



}
catch(ClassNotFoundException e)
{
e.printStackTrace();
System.err.println("Could not load DB2 driver \n");
System.err.println(e.getMessage());
System.exit(1);
}
try
{
String u="jdbc:db2://localhost:50000/EXAMPLE1";
//Connect to a database
conn = DriverManager.getConnection(u,"gururaj","sdmcet"); // check on URl try with blank or google it
// we connect to remote server. i am not sure abt local connection
System.out.println("Connected");
String query="select * from example1.sample";
DataRequest = conn.createStatement();

Results=DataRequest.executeQuery(query);

DataRequest.close();


}
catch (SQLException e)
{
e.printStackTrace();
System.out.println("SQL Exception: ");
System.err.println(e.getMessage());
}

return conn;
}

/**
* @param args
*/
public static void main(String args[])
{
conn=getConnection();
}


}

OUTPUT

run-main:
LOADED DB2 DRIVER
Connected
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704, SQLERRMC: EXAMPLE1.SAMPLE
SQL Exception:
at com.ibm.db2.jcc.c.fg.e(fg.java:1596)
at com.ibm.db2.jcc.c.fg.a(fg.java:1206)
at com.ibm.db2.jcc.b.gb.g(gb.java:140)
at com.ibm.db2.jcc.b.gb.a(gb.java:39)
at com.ibm.db2.jcc.b.w.a(w.java:34)
at com.ibm.db2.jcc.b.vb.g(vb.java:139)
at com.ibm.db2.jcc.c.fg.n(fg.java:1177)
at com.ibm.db2.jcc.c.fg.a(fg.java:1832)
at com.ibm.db2.jcc.c.fg.a(fg.java:473)
at com.ibm.db2.jcc.c.fg.executeQuery(fg.java:457)
at connect.getConnection(connect.java:61)
at connect.main(connect.java:82)
DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704, SQLERRMC: EXAMPLE1.SAMPLE
BUILD SUCCESSFUL (total time: 1 second)

Posted by Hi on Friday, 03.12.10 @ 19:55pm | #95519

how to set two columns as prmary key

Posted by kavitha on Wednesday, 08.19.09 @ 18:46pm | #90151

how do u get the date of next friday using jdbc

Posted by pavan on Wednesday, 08.29.07 @ 23:13pm | #24447

Hi friends
i want source of the jdbc.. how to connect jdbc n how to implement the JSP? send me ans..

Posted by karthik on Monday, 03.19.07 @ 11:56am | #12169

Ask programming questions?

 

 

Back to Tutorial

 

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name

 

 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.