Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: problem connecting in mssql

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    11
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default problem connecting in mssql

    hi guys i have a problem in connecting my jsp program in MSsql 2005
    i want to create a connection in my jsp program to MSsql database
    but theres an error of my work would you help me please in my problem
    thanks ... fo helping

    here is my code
    Code:
    PHP Code:
    <%@ page import="java.util.*" %>
    <%@ 
    page import="javax.sql.*;" %>
    <%@ 
    page import="java.sql.*;" %>
    <%@ 
    page import="java.util.Enumeration;" %>
             
             
             
    <
    html>
    <
    head><title>Sample MS connection</title></head>
    <
    body>
    <
    table>

    <% 
      
    Connection conn null;
     
            try {
     
                
    String dbURL "jdbc:sqlserver://192.168.0.103/mydatabase";
                
    String user "sa";
                
    String pass "";
                
    conn DriverManager.getConnection(dbURLuserpass);
                if (
    conn != null) {
                    
    DatabaseMetaData dm = (DatabaseMetaDataconn.getMetaData();
                    
    System.out.println("Driver name: " dm.getDriverName());
                    
    System.out.println("Driver version: " dm.getDriverVersion());
                    
    System.out.println("Product name: " dm.getDatabaseProductName());
                    
    System.out.println("Product version: " dm.getDatabaseProductVersion());
                }
     
            } catch (
    SQLException ex) {
                
    ex.printStackTrace();
            } 
    finally {
                try {
                    if (
    conn != null && !conn.isClosed()) {
                        
    conn.close();
                    }
                } catch (
    SQLException ex) {
                    
    ex.printStackTrace();
                }
            }
    %>

    </
    body>
    </
    html


  2. #2
    Member jdv's Avatar
    Join Date
    Jul 2014
    Location
    This Land
    Posts
    73
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Re: problem connecting in mssql

    You probably want to show the full stacktrace.

Similar Threads

  1. Problem connecting socket to port
    By Daryn in forum Java Networking
    Replies: 8
    Last Post: June 15th, 2014, 05:15 PM
  2. Problem connecting socket to port
    By Daryn in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 13th, 2014, 10:27 PM
  3. Jdbc connection mssql empty URL
    By Ziras in forum JDBC & Databases
    Replies: 0
    Last Post: February 17th, 2013, 06:09 AM
  4. Problem with connecting to DataBase
    By ocean1991 in forum JDBC & Databases
    Replies: 1
    Last Post: January 11th, 2013, 12:19 PM
  5. MSSQL Query Question
    By sravyen in forum JDBC & Databases
    Replies: 1
    Last Post: October 13th, 2009, 02:47 AM