Click here to Skip to main content
15,883,883 members
Home / Discussions / Java
   

Java

 
QuestionHow to use time picker in jsp? Pin
Phyo Thinzar Aung10-Mar-13 23:26
Phyo Thinzar Aung10-Mar-13 23:26 
AnswerRe: How to use time picker in jsp? Pin
Richard MacCutchan10-Mar-13 23:39
mveRichard MacCutchan10-Mar-13 23:39 
AnswerRe: How to use time picker in jsp? Pin
Shubhashish_Mandal14-Mar-13 0:26
professionalShubhashish_Mandal14-Mar-13 0:26 
QuestionHelp For Creating JSP invoice Pin
eMaM1519878-Mar-13 23:37
eMaM1519878-Mar-13 23:37 
AnswerRe: Help For Creating JSP invoice Pin
Richard MacCutchan10-Mar-13 23:37
mveRichard MacCutchan10-Mar-13 23:37 
QuestionAudio Sample Playback Pin
dusty_dex7-Mar-13 15:46
dusty_dex7-Mar-13 15:46 
AnswerRe: Audio Sample Playback Pin
Richard MacCutchan7-Mar-13 21:58
mveRichard MacCutchan7-Mar-13 21:58 
Questionjtds connection problem.... SQL Server 2012 Express Pin
MacRaider47-Mar-13 3:22
MacRaider47-Mar-13 3:22 
This is my first Java database application so I'm sure I'm missing something. This is the code I have...

Java
import java.sql.*;

public class ClsConn {
    private Connection conn;
    
    public Connection openConn() {
        try {
            System.out.println("Trying the connection now...");
            //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Class.forName("net.sourceforge.jtds.jdbc.Driver");
            //conn = DriverManager.getConnection("jdbc:odbc:IntranetSql");
            conn = java.sql.DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433;databaseName=Intranet;user=sa;password=passwrd");
            System.out.println("DSN Connection ok.");
        } catch (Exception e) {
            System.out.println("DSN Exception: " + e.getMessage());
            e.printStackTrace();
        }
        return conn;
    }
}


This was originally using a DSN, but that didn't seem to work (I was getting some interesting behavior) so I've gone to what you see there. I'm getting this error message: Cannot open database "Intranet" requested by the login. The login failed.

For reference on the same server for my asp pages I have the following which is working:
VB
Public Function OpenConnection() As Boolean
       Dim connString As String
       cnn = New SqlConnection
       connString = "server=localhost; uid=sa; pwd=password; database=intranet"
       Try
           cnn.ConnectionString = connString
           cnn.Open()
           Return True
       Catch ex As SqlException
           GlobalClasses.Client_Alert(ex.Message)
           Return False
       End Try

   End Function


I have opened up 1433 on the server so I have no idea what's going on... Any ideas would be greatly appreciated...

--Update 1--
For "fun" I just changed the Database to "Master" and the gosh darn thing "works"... well my query fails because the table it's looking for isn't in Master but the connection is working. I really need to start drinking or something. So it appears that everything is working for for some reason I can't see the database???

--Update 2--
Ok so I change my query figured that would be a good idea right? Nah... So I put in "use Intranet SELECT...." and get "Exception: Database 'Intranet' does not exist. Make sure that the name is entered correctly.". So I did what any good frustrated developer would do and opened up the mgmt studio for SQL Server and went to master and ran the same exact query with the "use..." (yes I cut and pasted it in just to be 100% sure) and imagine that it works. Yet my Java application is still saying it doesn't exist.
I am trying to figure this out not just waiting for an answer... Big Grin | :-D

--Update 3--
Connection string is now:
conn = java.sql.DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/master;user=sa;password=passwrd");

modified 7-Mar-13 10:46am.

AnswerRe: jtds connection problem.... SQL Server 2012 Express Pin
MacRaider47-Mar-13 7:03
MacRaider47-Mar-13 7:03 
AnswerHibernate Data base connection lost Pin
kvsravindrareddy12-Mar-13 21:04
kvsravindrareddy12-Mar-13 21:04 
SuggestionRe: jtds connection problem.... SQL Server 2012 Express Pin
Prasad Khandekar2-May-13 20:12
professionalPrasad Khandekar2-May-13 20:12 
QuestionRetails invoice Pin
eMaM1519877-Mar-13 0:39
eMaM1519877-Mar-13 0:39 
AnswerRe: Retails invoice Pin
Sandeep Mewara7-Mar-13 1:24
mveSandeep Mewara7-Mar-13 1:24 
Questionjava help Pin
okedi5-Mar-13 22:15
okedi5-Mar-13 22:15 
AnswerRe: java help Pin
Richard MacCutchan5-Mar-13 22:22
mveRichard MacCutchan5-Mar-13 22:22 
Questiondemende help Pin
لحن الأماني5-Mar-13 9:50
لحن الأماني5-Mar-13 9:50 
AnswerRe: demende help Pin
Master.Man19805-Mar-13 10:21
Master.Man19805-Mar-13 10:21 
Questiondemende help Pin
لحن الأماني5-Mar-13 9:50
لحن الأماني5-Mar-13 9:50 
AnswerRe: demende help Pin
dusty_dex6-Mar-13 4:52
dusty_dex6-Mar-13 4:52 
Questiondemende d'aide Pin
لحن الأماني5-Mar-13 8:17
لحن الأماني5-Mar-13 8:17 
AnswerRe: demende d'aide Pin
Jibesh5-Mar-13 8:47
professionalJibesh5-Mar-13 8:47 
SuggestionRe: demende d'aide Pin
Richard MacCutchan5-Mar-13 9:46
mveRichard MacCutchan5-Mar-13 9:46 
GeneralRe: demende d'aide Pin
dusty_dex6-Mar-13 0:31
dusty_dex6-Mar-13 0:31 
GeneralRe: demende d'aide Pin
Richard MacCutchan6-Mar-13 0:39
mveRichard MacCutchan6-Mar-13 0:39 
GeneralRe: demende d'aide Pin
dusty_dex6-Mar-13 4:43
dusty_dex6-Mar-13 4:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.