| | |
tough to get me
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2008
Posts: 40
Reputation:
Solved Threads: 0
consider the following snippet:
import java.sql.*;
public class test
{
public static void main(String args[])
{
try
{
Class.forNameI"sun.jdbc.odbc.JdbcOdbcDriverManager");
Connection cn;
cn=DriverManager.getConnection("jdbc:odbc","username","password");
Statement st=cn.createStatement();
st.executeQuery("select * from emp");
System.out.println("Succeed");
}
catch(Exception e)
{
System.out.println("Faild");
}
finall()
{
system.out.println("Always");
}
}
}
what will be the result
import java.sql.*;
public class test
{
public static void main(String args[])
{
try
{
Class.forNameI"sun.jdbc.odbc.JdbcOdbcDriverManager");
Connection cn;
cn=DriverManager.getConnection("jdbc:odbc","username","password");
Statement st=cn.createStatement();
st.executeQuery("select * from emp");
System.out.println("Succeed");
}
catch(Exception e)
{
System.out.println("Faild");
}
finall()
{
system.out.println("Always");
}
}
}
what will be the result
Thanks & Regards
Ms. Dipti
Ms. Dipti
Error while compiling, as there is nothing like Class.forNameI"sun.jdbc.odbc.JdbcOdbcDriverManager");, finall(); system.out.println("Always");
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Sep 2008
Posts: 40
Reputation:
Solved Threads: 0
•
•
•
•
Error while compiling, as there is nothing like Class.forNameI"sun.jdbc.odbc.JdbcOdbcDriverManager");, finall(); system.out.println("Always");
It's .........
Class.forName("sun.jdbc.odbc.JdbcOdbcDriverManager");
& other is......
finally
{
System.out.println("Always");
}
Thanks & Regards
Ms. Dipti
Ms. Dipti
Result can be anything Succeed and Always if there been no issue, it can be Faild if table doesn't exist, or it can be number of errors because of various reasons.
So you better post what errors you getting.
PS: Gravely mistake in your code, you never closed Connection after you finished with DB
So you better post what errors you getting.
PS: Gravely mistake in your code, you never closed Connection after you finished with DB
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- When the going gets tough (Assembly)
- Writing to an Access Database (Visual Basic 4 / 5 / 6)
- Data Recovery (Storage)
- Interests Anyone? (Geeks' Lounge)
- Tell us about yourself! (Community Introductions)
- Where to get started with Web Programming (IT Professionals' Lounge)
- No Posts? (DaniWeb Community Feedback)
- Streeeeetched the site (DaniWeb Community Feedback)
- New Announcements! (DaniWeb Community Feedback)
Other Threads in the Java Forum
- Previous Thread: About JDBC driver
- Next Thread: Oracle 9i and jdbc1.4 discrepancy
| Thread Tools | Search this Thread |
Tag cloud for Java
-xlint 2dgraphics android api apple applet application applications arguments array arrays automation bank bidirectional binary bluetooth chat class classes client code collision component database db development draw eclipse eclipsedevelopment error event exception file fractal game givemetehcodez graphics gui helpwithhomework homework html ide image input integer integration j2me jarfile java javadesktopapplications javafx javaprojects jmf jni jpanel julia learningresources linux list loop map method methods mobile netbeans newbie number oracle print problem program programming project projectideas recursion researchinmotion scanner screen server service set size sms socket sort sorting sql sqlserver state string swing swt tcp test text-file threads time tree web windows






