954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

tough to get me

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

cutedipti
Light Poster
45 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

Error while compiling, as there is nothing like Class.forNameI"sun.jdbc.odbc.JdbcOdbcDriverManager");, finall(); system.out.println("Always");

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 
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");
}Actualy i am about :
JDBC-ODBC bridge driver
OR JDBC-Net pure java driver

cutedipti
Light Poster
45 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

Wrap up source code with bb code tags.
>what will be the result
Have you compiled this code?

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

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

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You